/[LeafOK_CVS]/lbbs/src/bbs_main.c
ViewVC logotype

Diff of /lbbs/src/bbs_main.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.121 by sysadm, Thu Dec 18 10:43:48 2025 UTC Revision 1.122 by sysadm, Fri Dec 19 06:16:26 2025 UTC
# Line 43  static void child_proc_sig_usr1_handler( Line 43  static void child_proc_sig_usr1_handler(
43          // Restart log          // Restart log
44          if (log_restart() < 0)          if (log_restart() < 0)
45          {          {
46                  log_error("Restart logging failed\n");                  log_error("Restart logging failed");
47          }          }
48  }  }
49    
# Line 64  int bbs_welcome(void) Line 64  int bbs_welcome(void)
64    
65          if (get_user_online_list_count(&u_online, &u_anonymous) < 0)          if (get_user_online_list_count(&u_online, &u_anonymous) < 0)
66          {          {
67                  log_error("get_user_online_list_count() error\n");                  log_error("get_user_online_list_count() error");
68                  u_online = 0;                  u_online = 0;
69          }          }
70          u_online += u_anonymous;          u_online += u_anonymous;
# Line 76  int bbs_welcome(void) Line 76  int bbs_welcome(void)
76    
77          if (get_user_list_count(&u_total) < 0)          if (get_user_list_count(&u_total) < 0)
78          {          {
79                  log_error("get_user_list_count() error\n");                  log_error("get_user_list_count() error");
80                  u_total = 0;                  u_total = 0;
81          }          }
82    
83          if (get_user_login_count(&u_login_count) < 0)          if (get_user_login_count(&u_login_count) < 0)
84          {          {
85                  log_error("get_user_login_count() error\n");                  log_error("get_user_login_count() error");
86                  u_login_count = 0;                  u_login_count = 0;
87          }          }
88    
# Line 122  int bbs_logout(void) Line 122  int bbs_logout(void)
122    
123          display_file(DATA_GOODBYE, 1);          display_file(DATA_GOODBYE, 1);
124    
125          log_common("User [%s] (uid=%d) logout, idle for %ld seconds since last input\n",          log_common("User [%s] (uid=%d) logout, idle for %ld seconds since last input",
126                             BBS_username, BBS_priv.uid, time(NULL) - BBS_last_access_tm);                             BBS_username, BBS_priv.uid, time(NULL) - BBS_last_access_tm);
127    
128          return 0;          return 0;
# Line 171  int bbs_center() Line 171  int bbs_center()
171                  if (ch != KEY_NULL && ch != KEY_TIMEOUT)                  if (ch != KEY_NULL && ch != KEY_TIMEOUT)
172                  {                  {
173                          BBS_last_access_tm = time(NULL);                          BBS_last_access_tm = time(NULL);
174                          log_debug("Debug: BBS_last_access_tm is updated\n");                          log_debug("Debug: BBS_last_access_tm is updated");
175                  }                  }
176    
177                  if (bbs_menu.choose_step == 0 && time(NULL) - t_last_action >= 10)                  if (bbs_menu.choose_step == 0 && time(NULL) - t_last_action >= 10)
# Line 186  int bbs_center() Line 186  int bbs_center()
186    
187                  if (user_online_update("MENU") < 0)                  if (user_online_update("MENU") < 0)
188                  {                  {
189                          log_error("user_online_update(MENU) error\n");                          log_error("user_online_update(MENU) error");
190                  }                  }
191    
192                  switch (ch)                  switch (ch)
193                  {                  {
194                  case KEY_NULL: // broken pipe                  case KEY_NULL: // broken pipe
195                          log_debug("KEY_NULL\n");                          log_debug("KEY_NULL");
196                          loop = 0;                          loop = 0;
197                          break;                          break;
198                  case KEY_TIMEOUT:                  case KEY_TIMEOUT:
199                          if (time(NULL) - BBS_last_access_tm >= BBS_max_user_idle_time)                          if (time(NULL) - BBS_last_access_tm >= BBS_max_user_idle_time)
200                          {                          {
201                                  log_debug("User input timeout\n");                                  log_debug("User input timeout");
202                                  loop = 0;                                  loop = 0;
203                                  break;                                  break;
204                          }                          }
# Line 253  int bbs_charset_select() Line 253  int bbs_charset_select()
253                  case 'G':                  case 'G':
254                          if (io_conv_init("GBK") < 0)                          if (io_conv_init("GBK") < 0)
255                          {                          {
256                                  log_error("io_conv_init(%s) error\n", "GBK");                                  log_error("io_conv_init(%s) error", "GBK");
257                                  return -1;                                  return -1;
258                          }                          }
259                          break;                          break;
# Line 301  int bbs_main() Line 301  int bbs_main()
301          act.sa_handler = SIG_IGN;          act.sa_handler = SIG_IGN;
302          if (sigaction(SIGHUP, &act, NULL) == -1)          if (sigaction(SIGHUP, &act, NULL) == -1)
303          {          {
304                  log_error("set signal action of SIGHUP error: %d\n", errno);                  log_error("set signal action of SIGHUP error: %d", errno);
305                  goto cleanup;                  goto cleanup;
306          }          }
307          act.sa_handler = SIG_DFL;          act.sa_handler = SIG_DFL;
308          if (sigaction(SIGCHLD, &act, NULL) == -1)          if (sigaction(SIGCHLD, &act, NULL) == -1)
309          {          {
310                  log_error("set signal action of SIGCHLD error: %d\n", errno);                  log_error("set signal action of SIGCHLD error: %d", errno);
311                  goto cleanup;                  goto cleanup;
312          }          }
313          act.sa_handler = child_proc_sig_usr1_handler;          act.sa_handler = child_proc_sig_usr1_handler;
314          if (sigaction(SIGUSR1, &act, NULL) == -1)          if (sigaction(SIGUSR1, &act, NULL) == -1)
315          {          {
316                  log_error("set signal action of SIGUSR1 error: %d\n", errno);                  log_error("set signal action of SIGUSR1 error: %d", errno);
317                  goto cleanup;                  goto cleanup;
318          }          }
319    
# Line 346  int bbs_main() Line 346  int bbs_main()
346          // Set default charset          // Set default charset
347          if (io_conv_init(BBS_default_charset) < 0)          if (io_conv_init(BBS_default_charset) < 0)
348          {          {
349                  log_error("io_conv_init(%s) error\n", BBS_default_charset);                  log_error("io_conv_init(%s) error", BBS_default_charset);
350                  goto cleanup;                  goto cleanup;
351          }          }
352    
# Line 380  int bbs_main() Line 380  int bbs_main()
380          {          {
381                  goto cleanup;                  goto cleanup;
382          }          }
383          log_common("User [%s] (uid=%d) login from %s:%d\n",          log_common("User [%s] (uid=%d) login from %s:%d",
384                             BBS_username, BBS_priv.uid, hostaddr_client, port_client);                             BBS_username, BBS_priv.uid, hostaddr_client, port_client);
385    
386          // Check EULA update status          // Check EULA update status
# Line 393  int bbs_main() Line 393  int bbs_main()
393          // Load section aid locations          // Load section aid locations
394          if (section_aid_locations_load(BBS_priv.uid) < 0)          if (section_aid_locations_load(BBS_priv.uid) < 0)
395          {          {
396                  log_error("article_view_log_load() error\n");                  log_error("article_view_log_load() error");
397                  goto cleanup;                  goto cleanup;
398          }          }
399    
400          // Load article view log          // Load article view log
401          if (article_view_log_load(BBS_priv.uid, &BBS_article_view_log, 0) < 0)          if (article_view_log_load(BBS_priv.uid, &BBS_article_view_log, 0) < 0)
402          {          {
403                  log_error("article_view_log_load() error\n");                  log_error("article_view_log_load() error");
404                  goto cleanup;                  goto cleanup;
405          }          }
406    
407          // Load article favorite          // Load article favorite
408          if (article_favor_load(BBS_priv.uid, &BBS_article_favor, 0) < 0)          if (article_favor_load(BBS_priv.uid, &BBS_article_favor, 0) < 0)
409          {          {
410                  log_error("article_favor_load() error\n");                  log_error("article_favor_load() error");
411                  goto cleanup;                  goto cleanup;
412          }          }
413    
414          // Init editor memory pool          // Init editor memory pool
415          if (editor_memory_pool_init() < 0)          if (editor_memory_pool_init() < 0)
416          {          {
417                  log_error("editor_memory_pool_init() error\n");                  log_error("editor_memory_pool_init() error");
418                  goto cleanup;                  goto cleanup;
419          }          }
420    
# Line 432  int bbs_main() Line 432  int bbs_main()
432          // Save section aid locations          // Save section aid locations
433          if (section_aid_locations_save(BBS_priv.uid) < 0)          if (section_aid_locations_save(BBS_priv.uid) < 0)
434          {          {
435                  log_error("article_view_log_save() error\n");                  log_error("article_view_log_save() error");
436          }          }
437    
438          // Save incremental article view log          // Save incremental article view log
439          if (article_view_log_save_inc(&BBS_article_view_log) < 0)          if (article_view_log_save_inc(&BBS_article_view_log) < 0)
440          {          {
441                  log_error("article_view_log_save_inc() error\n");                  log_error("article_view_log_save_inc() error");
442          }          }
443    
444          // Save incremental article favorite          // Save incremental article favorite
445          if (article_favor_save_inc(&BBS_article_favor) < 0)          if (article_favor_save_inc(&BBS_article_favor) < 0)
446          {          {
447                  log_error("article_favor_save_inc() error\n");                  log_error("article_favor_save_inc() error");
448          }          }
449    
450  cleanup:  cleanup:


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

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