| 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" |
| 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 |
{ |
{ |
| 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 |
|
|
| 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 |
} |
} |