--- lbbs/src/article_view_log.c 2025/06/07 10:00:10 1.3 +++ lbbs/src/article_view_log.c 2025/10/13 00:18:40 1.8 @@ -15,13 +15,10 @@ ***************************************************************************/ #include "article_view_log.h" -#include "log.h" #include "common.h" #include "database.h" +#include "log.h" #include - -#define _XOPEN_SOURCE 500 -#define _POSIX_C_SOURCE 200809L #include ARTICLE_VIEW_LOG BBS_article_view_log; @@ -123,7 +120,7 @@ int article_view_log_unload(ARTICLE_VIEW int article_view_log_save_inc(const ARTICLE_VIEW_LOG *p_view_log) { - MYSQL *db; + MYSQL *db = NULL; char sql[SQL_BUFFER_LEN]; char tuple_tmp[LINE_BUFFER_LEN]; int i; @@ -161,6 +158,7 @@ int article_view_log_save_inc(const ARTI if (mysql_query(db, sql) != 0) { log_error("Add view_article_log error: %s\n", mysql_error(db)); + mysql_close(db); return -3; } @@ -337,7 +335,7 @@ int article_view_log_set_viewed(int32_t } // Merge if Inc is full - if (p_view_log->aid_inc_cnt >= MAX_AID_INC_CNT) + if (p_view_log->aid_inc_cnt >= MAX_VIEWED_AID_INC_CNT) { // Save incremental article view log if (article_view_log_save_inc(p_view_log) < 0)