--- lbbs/src/net_server.c 2025/05/13 10:42:21 1.31 +++ lbbs/src/net_server.c 2025/05/16 14:09:31 1.35 @@ -24,6 +24,7 @@ #include "io.h" #include "fork.h" #include "menu.h" +#include "file_loader.h" #include #include #include @@ -47,6 +48,7 @@ int net_server(const char *hostaddr, in_ int nfds, epollfd; siginfo_t siginfo; int sd_notify_stopping = 0; + MENU_SET *p_bbs_menu_new; socket_server = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); @@ -116,9 +118,9 @@ int net_server(const char *hostaddr, in_ // Startup complete sd_notifyf(0, "READY=1\n" - "STATUS=Accepting incoming connections...\n" + "STATUS=Listening at %s:%d\n" "MAINPID=%d", - getpid()); + hostaddr_server, port_server, getpid()); while (!SYS_server_exit || SYS_child_process_count > 0) { @@ -166,16 +168,47 @@ int net_server(const char *hostaddr, in_ { SYS_menu_reload = 0; - if (reload_menu(&bbs_menu) < 0) + p_bbs_menu_new = calloc(1, sizeof(MENU_SET)); + if (p_bbs_menu_new == NULL) { + log_error("OOM: calloc(MENU_SET)\n"); + } + else if (load_menu(p_bbs_menu_new, CONF_MENU) < 0) + { + unload_menu(p_bbs_menu_new); + free(p_bbs_menu_new); + log_error("Reload menu failed\n"); } else { + unload_menu_shm(p_bbs_menu_new); + + unload_menu(p_bbs_menu); + free(p_bbs_menu); + + p_bbs_menu = p_bbs_menu_new; + p_bbs_menu_new = NULL; + log_std("Reload menu successfully\n"); } } + if (SYS_data_file_reload && !SYS_server_exit) + { + SYS_data_file_reload = 0; + + for (int i = 0; i < data_files_load_startup_count; i++) + { + if (load_file_mmap(data_files_load_startup[i]) < 0) + { + log_error("load_file_mmap(%s) error\n", data_files_load_startup[i]); + } + } + + log_std("Reload data files successfully\n"); + } + nfds = epoll_wait(epollfd, events, MAX_EVENTS, 100); // 0.1 second if (nfds < 0)