/[LeafOK_CVS]/lbbs/src/user_list.c
ViewVC logotype

Diff of /lbbs/src/user_list.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.26 by sysadm, Tue Nov 4 13:49:51 2025 UTC Revision 1.31 by sysadm, Sun Nov 9 06:44:02 2025 UTC
# Line 3  Line 3 
3   * user_list   * user_list
4   *   - data model and basic operations of (online) user list   *   - data model and basic operations of (online) user list
5   *   *
6   * Copyright (C) 2004-2025 by Leaflet <leaflet@leafok.com>   * Copyright (C) 2004-2025  Leaflet <leaflet@leafok.com>
7   */   */
8    
9  #include "common.h"  #include "common.h"
# Line 33  union semun Line 33  union semun
33  };  };
34  #endif // #ifdef _SEM_SEMUN_UNDEFINED  #endif // #ifdef _SEM_SEMUN_UNDEFINED
35    
36  #define USER_LIST_TRY_LOCK_WAIT_TIME 1 // second  enum _user_list_constant_t
37  #define USER_LIST_TRY_LOCK_TIMES 10  {
38            USER_LIST_TRY_LOCK_WAIT_TIME = 1, // second
39            USER_LIST_TRY_LOCK_TIMES = 10,
40    };
41    
42  struct user_list_pool_t  struct user_list_pool_t
43  {  {
# Line 181  int user_list_load(MYSQL *db, USER_LIST Line 184  int user_list_load(MYSQL *db, USER_LIST
184                  p_list->users[i].signup_dt = (row[8] == NULL ? 0 : atol(row[8]));                  p_list->users[i].signup_dt = (row[8] == NULL ? 0 : atol(row[8]));
185                  p_list->users[i].last_login_dt = (row[9] == NULL ? 0 : atol(row[9]));                  p_list->users[i].last_login_dt = (row[9] == NULL ? 0 : atol(row[9]));
186                  p_list->users[i].last_logout_dt = (row[10] == NULL ? 0 : atol(row[10]));                  p_list->users[i].last_logout_dt = (row[10] == NULL ? 0 : atol(row[10]));
187                  p_list->users[i].birthday = (row[10] == NULL ? 0 : atol(row[11]));                  p_list->users[i].birthday = (row[11] == NULL ? 0 : atol(row[11]));
188                  intro_len = strlen((row[12] == NULL ? "" : row[12]));                  intro_len = strlen((row[12] == NULL ? "" : row[12]));
189                  if (intro_len >= sizeof(p_list->user_intro_buf) - 1 - intro_buf_offset)                  if (intro_len >= sizeof(p_list->user_intro_buf) - 1 - intro_buf_offset)
190                  {                  {
# Line 335  int user_online_list_load(MYSQL *db, USE Line 338  int user_online_list_load(MYSQL *db, USE
338                  }                  }
339    
340                  qsort(p_online_list->index_uid, (size_t)user_cnt, sizeof(USER_INFO_INDEX_UID), user_info_index_uid_comp);                  qsort(p_online_list->index_uid, (size_t)user_cnt, sizeof(USER_INFO_INDEX_UID), user_info_index_uid_comp);
   
 #ifdef _DEBUG  
                 log_error("Rebuild index of %d online users\n", user_cnt);  
 #endif  
341          }          }
342    
343          p_online_list->user_count = user_cnt;          p_online_list->user_count = user_cnt;
344          p_online_list->guest_count = guest_cnt;          p_online_list->guest_count = guest_cnt;
345    
 #ifdef _DEBUG  
         log_error("Loaded %d online users and %d guest users\n", p_list->user_count, p_list->guest_count);  
 #endif  
   
346  cleanup:  cleanup:
347          mysql_free_result(rs);          mysql_free_result(rs);
348    
# Line 503  void user_list_pool_cleanup(void) Line 498  void user_list_pool_cleanup(void)
498                  log_error("shmdt(shmid = %d) error (%d)\n", shmid, errno);                  log_error("shmdt(shmid = %d) error (%d)\n", shmid, errno);
499          }          }
500    
501          if (shmctl(shmid, IPC_RMID, NULL) == -1)          if (shmid != 0 && shmctl(shmid, IPC_RMID, NULL) == -1)
502          {          {
503                  log_error("shmctl(shmid = %d, IPC_RMID) error (%d)\n", shmid, errno);                  log_error("shmctl(shmid = %d, IPC_RMID) error (%d)\n", shmid, errno);
504          }          }


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1