/[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.23 by sysadm, Sat Nov 1 10:35:42 2025 UTC Revision 1.24 by sysadm, Sun Nov 2 04:30:29 2025 UTC
# Line 55  struct user_list_pool_t Line 55  struct user_list_pool_t
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    
# Line 94  static int user_list_rw_lock(int semid); Line 95  static int user_list_rw_lock(int semid);
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  {  {
# Line 360  cleanup: Line 362  cleanup:
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;
# Line 558  int user_list_pool_reload(int online_use Line 593  int user_list_pool_reload(int online_use
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          {          {
# Line 925  int get_user_online_list_count(int *p_us Line 967  int get_user_online_list_count(int *p_us
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  {  {


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

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