| 55 |
USER_ONLINE_LIST *p_online_current; |
USER_ONLINE_LIST *p_online_current; |
| 56 |
USER_ONLINE_LIST *p_online_new; |
USER_ONLINE_LIST *p_online_new; |
| 57 |
USER_STAT_MAP user_stat_map; |
USER_STAT_MAP user_stat_map; |
| 58 |
|
int user_login_count; |
| 59 |
}; |
}; |
| 60 |
typedef struct user_list_pool_t USER_LIST_POOL; |
typedef struct user_list_pool_t USER_LIST_POOL; |
| 61 |
|
|
| 95 |
|
|
| 96 |
static int user_list_load(MYSQL *db, USER_LIST *p_list); |
static int user_list_load(MYSQL *db, USER_LIST *p_list); |
| 97 |
static int user_online_list_load(MYSQL *db, USER_ONLINE_LIST *p_list); |
static int user_online_list_load(MYSQL *db, USER_ONLINE_LIST *p_list); |
| 98 |
|
static int user_login_count_load(MYSQL *db); |
| 99 |
|
|
| 100 |
static int user_info_index_uid_comp(const void *ptr1, const void *ptr2) |
static int user_info_index_uid_comp(const void *ptr1, const void *ptr2) |
| 101 |
{ |
{ |
| 362 |
return ret; |
return ret; |
| 363 |
} |
} |
| 364 |
|
|
| 365 |
|
int user_login_count_load(MYSQL *db) |
| 366 |
|
{ |
| 367 |
|
MYSQL_RES *rs = NULL; |
| 368 |
|
MYSQL_ROW row; |
| 369 |
|
char sql[SQL_BUFFER_LEN]; |
| 370 |
|
|
| 371 |
|
if (db == NULL) |
| 372 |
|
{ |
| 373 |
|
log_error("NULL pointer error\n"); |
| 374 |
|
return -1; |
| 375 |
|
} |
| 376 |
|
|
| 377 |
|
snprintf(sql, sizeof(sql), |
| 378 |
|
"SELECT ID FROM user_login_log ORDER BY ID DESC LIMIT 1"); |
| 379 |
|
if (mysql_query(db, sql) != 0) |
| 380 |
|
{ |
| 381 |
|
log_error("Query user_login_log error: %s\n", mysql_error(db)); |
| 382 |
|
return -2; |
| 383 |
|
} |
| 384 |
|
if ((rs = mysql_store_result(db)) == NULL) |
| 385 |
|
{ |
| 386 |
|
log_error("Get user_login_log data failed\n"); |
| 387 |
|
return -2; |
| 388 |
|
} |
| 389 |
|
if ((row = mysql_fetch_row(rs))) |
| 390 |
|
{ |
| 391 |
|
p_user_list_pool->user_login_count = atoi(row[0]); |
| 392 |
|
} |
| 393 |
|
mysql_free_result(rs); |
| 394 |
|
|
| 395 |
|
return 0; |
| 396 |
|
} |
| 397 |
|
|
| 398 |
int user_list_pool_init(const char *filename) |
int user_list_pool_init(const char *filename) |
| 399 |
{ |
{ |
| 400 |
int shmid; |
int shmid; |
| 593 |
ret = -2; |
ret = -2; |
| 594 |
goto cleanup; |
goto cleanup; |
| 595 |
} |
} |
| 596 |
|
|
| 597 |
|
if (user_login_count_load(db) < 0) |
| 598 |
|
{ |
| 599 |
|
log_error("user_login_count_load() error\n"); |
| 600 |
|
ret = -2; |
| 601 |
|
goto cleanup; |
| 602 |
|
} |
| 603 |
} |
} |
| 604 |
else |
else |
| 605 |
{ |
{ |
| 967 |
|
|
| 968 |
return 0; |
return 0; |
| 969 |
} |
} |
| 970 |
|
|
| 971 |
|
int get_user_login_count(int *p_login_cnt) |
| 972 |
|
{ |
| 973 |
|
if (p_login_cnt == NULL) |
| 974 |
|
{ |
| 975 |
|
log_error("NULL pointer error\n"); |
| 976 |
|
return -1; |
| 977 |
|
} |
| 978 |
|
|
| 979 |
|
*p_login_cnt = p_user_list_pool->user_login_count; |
| 980 |
|
|
| 981 |
|
return 0; |
| 982 |
|
} |
| 983 |
|
|
| 984 |
int query_user_info(int32_t id, USER_INFO *p_user) |
int query_user_info(int32_t id, USER_INFO *p_user) |
| 985 |
{ |
{ |