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

Diff of /lbbs/src/section_list_loader.c

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

Revision 1.50 by sysadm, Tue Oct 14 00:57:06 2025 UTC Revision 1.53 by sysadm, Wed Oct 22 04:48:53 2025 UTC
# Line 22  Line 22 
22  #include "log.h"  #include "log.h"
23  #include "menu.h"  #include "menu.h"
24  #include "section_list_loader.h"  #include "section_list_loader.h"
25    #include "user_list.h"
26  #include "user_priv.h"  #include "user_priv.h"
27  #include <errno.h>  #include <errno.h>
28  #include <signal.h>  #include <signal.h>
# Line 137  int load_section_config_from_db(int upda Line 138  int load_section_config_from_db(int upda
138                                  break;                                  break;
139                          }                          }
140    
141                          strncpy(p_section->sname, row[1], sizeof(p_section->sname) - 1);                          if (section_list_update(p_section, row[1], row[2], master_list) < 0)
142                          p_section->sname[sizeof(p_section->sname) - 1] = '\0';                          {
143                          strncpy(p_section->stitle, row[2], sizeof(p_section->stitle) - 1);                                  log_error("section_list_update(sid=%d) error\n", p_section->sid);
144                          p_section->stitle[sizeof(p_section->stitle) - 1] = '\0';                                  ret = -4;
145                          strncpy(p_section->master_list, master_list, sizeof(p_section->master_list) - 1);                                  break;
146                          p_section->master_list[sizeof(p_section->master_list) - 1] = '\0';                          }
147                  }                  }
148    
149                  p_section->class_id = atoi(row[3]);                  p_section->class_id = atoi(row[3]);
# Line 689  int section_list_loader_launch(void) Line 690  int section_list_loader_launch(void)
690          int article_count;          int article_count;
691          int load_count;          int load_count;
692          int last_mid;          int last_mid;
693          int i;          time_t tm_section_list_reload = 0;
694            time_t tm_user_list_reload = 0;
695            time_t tm_user_online_list_reload = 0;
696    
697          if (section_list_loader_pid != 0)          if (section_list_loader_pid != 0)
698          {          {
# Line 734  int section_list_loader_launch(void) Line 737  int section_list_loader_launch(void)
737          // Do section data loader periodically          // Do section data loader periodically
738          while (!SYS_server_exit)          while (!SYS_server_exit)
739          {          {
740                    tm_section_list_reload = time(NULL);
741    
742                  if (SYS_conf_reload)                  if (SYS_conf_reload)
743                  {                  {
744                          SYS_conf_reload = 0;                          SYS_conf_reload = 0;
# Line 799  int section_list_loader_launch(void) Line 804  int section_list_loader_launch(void)
804                          log_common("Proceeded %d article logs, last_mid = %d\n", last_article_op_log_mid - last_mid, last_article_op_log_mid);                          log_common("Proceeded %d article logs, last_mid = %d\n", last_article_op_log_mid - last_mid, last_article_op_log_mid);
805                  }                  }
806    
807                  if (SYS_conf_reload)                  // Reload user list
808                    if (time(NULL) - tm_user_list_reload >= BBS_user_list_load_interval)
809                  {                  {
810                          continue;                          if (user_list_pool_reload(0) < 0)
811                            {
812                                    log_error("user_list_pool_reload(all_user) error\n");
813                            }
814                            tm_user_list_reload = time(NULL);
815                    }
816    
817                    // Reload user online list
818                    if (time(NULL) - tm_user_online_list_reload >= BBS_user_online_list_load_interval)
819                    {
820                            if (user_list_pool_reload(1) < 0)
821                            {
822                                    log_error("user_list_pool_reload(online_user) error\n");
823                            }
824                            tm_user_online_list_reload = time(NULL);
825                  }                  }
826    
827                  for (i = 0; i < BBS_section_list_load_interval && !SYS_server_exit && !SYS_conf_reload; i++)                  // Wait for BBS_section_list_load_interval seconds
828                    while (!SYS_server_exit && time(NULL) - tm_section_list_reload < BBS_section_list_load_interval)
829                  {                  {
830                          sleep(1);                          sleep(1);
831                  }                  }
# Line 821  int section_list_loader_launch(void) Line 842  int section_list_loader_launch(void)
842          detach_section_list_shm();          detach_section_list_shm();
843          detach_article_block_shm();          detach_article_block_shm();
844          detach_trie_dict_shm();          detach_trie_dict_shm();
845            detach_user_list_pool_shm();
846    
847          log_common("Section list loader process exit normally\n");          log_common("Section list loader process exit normally\n");
848          log_end();          log_end();


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

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