message: Optimize table, prevent deadlock, force unlock when timeout
diff: @@ -177,10 +177,14 @@ static sw_inline swTableColumn* swTableColumn_get(swTable *table, const std::str
  }
  }
  +#define SW_TABLE_FORCE_UNLOCK_TIME 2
  +
  static sw_inline void swTableRow_lock(swTableRow *row)
  {
  sw_atomic_t *lock = &row->lock;
  uint32_t i, n;
  + time_t t = 0;
  +
  while (1)
  {
  if (*lock == 0 && sw_atomic_cmp_set(lock, 0, 1))
  @@ -202,11 +206,33 @@ static sw_inline void swTableRow_lock(swTableRow *row)
  }
  }
  }
  + /**
  + * The process occupied by the resource no longer exists,
  + * indicating that OOM occurred during the locking process,
  + * forced to unlock
  + */
  if (kill(row->lock_pid, 0) < 0 && errno == ESRCH)
  {
  *lock = 1;
  goto _success;
  }
  + /**
  + * Mark time
  + */
  + if (t == 0)
  + {
  + t = time(NULL);
  + }
  + /**
  + * The deadlock time exceeds 2 seconds (SW_TABLE_FORCE_UNLOCK_TIME),
  + * indicating that the lock process has OOM,
  + * and the PID has been reused, forcing the unlock
  + */
  + else if (time(NULL) - t > SW_TABLE_FORCE_UNLOCK_TIME)
  + {
  + *lock = 1;
  + goto _success;
  + }
  swYield();
  }
  }
  