--- lbbs/src/main.c 2025/05/27 00:54:01 1.43 +++ lbbs/src/main.c 2025/05/29 00:52:09 1.47 @@ -55,6 +55,8 @@ int main(int argc, char *argv[]) int std_log_redir = 0; int error_log_redir = 0; FILE *fp; + int ret; + int last_aid; // Parse args for (int i = 1; i < argc; i++) @@ -222,20 +224,35 @@ int main(int argc, char *argv[]) goto cleanup; } - // Load section config - if (append_articles_from_db(0, 1) < 0) + set_last_article_op_log_from_db(); + last_aid = 0; + + // Load section articles + do { - log_error("append_articles_from_db(0, 1) error\n"); - goto cleanup; - } + if ((ret = append_articles_from_db(last_aid + 1, 1, LOAD_ARTICLE_COUNT_LIMIT)) < 0) + { + log_error("append_articles_from_db(0, 1, %d) error\n", LOAD_ARTICLE_COUNT_LIMIT); + goto cleanup; + } - log_std("Debug: last_aid = %d\n", article_block_last_aid()); + last_aid = article_block_last_aid(); + } while (ret == LOAD_ARTICLE_COUNT_LIMIT); + + log_std("Initially load %d articles, last_aid = %d\n", article_block_article_count(), article_block_last_aid()); // Set signal handler signal(SIGHUP, sig_hup_handler); signal(SIGCHLD, sig_chld_handler); signal(SIGTERM, sig_term_handler); + // Launch section_list_loader process + if (section_list_loader_launch() < 0) + { + log_error("section_list_loader_launch() error\n"); + goto cleanup; + } + // Initialize socket server net_server(BBS_address, BBS_port);