/[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.36 by sysadm, Wed Jun 25 01:50:14 2025 UTC Revision 1.38 by sysadm, Thu Jun 26 12:17:02 2025 UTC
# Line 30  Line 30 
30  int section_list_loader_pid;  int section_list_loader_pid;
31  int last_article_op_log_mid;  int last_article_op_log_mid;
32    
33  int load_section_config_from_db(int reload)  int load_section_config_from_db(int update_gen_ex)
34  {  {
35          MYSQL *db = NULL;          MYSQL *db = NULL;
36          MYSQL_RES *rs = NULL, *rs2 = NULL;          MYSQL_RES *rs = NULL, *rs2 = NULL;
# Line 148  int load_section_config_from_db(int relo Line 148  int load_section_config_from_db(int relo
148                  p_section->enable = (int8_t)atoi(row[6]);                  p_section->enable = (int8_t)atoi(row[6]);
149    
150                  // Update gen_ex menu set                  // Update gen_ex menu set
151                  if (reload && p_section->enable && atoi(row[7]) > p_section->ex_menu_tm)                  if (update_gen_ex && p_section->enable && atoi(row[7]) > p_section->ex_menu_tm)
152                  {                  {
153                          snprintf(ex_menu_conf, sizeof(ex_menu_conf), "%s/%d", VAR_GEN_EX_MENU_DIR, p_section->sid);                          snprintf(ex_menu_conf, sizeof(ex_menu_conf), "%s/%d", VAR_GEN_EX_MENU_DIR, p_section->sid);
154    
# Line 704  int section_list_loader_launch(void) Line 704  int section_list_loader_launch(void)
704    
705          // Set signal handler          // Set signal handler
706          act.sa_handler = SIG_DFL;          act.sa_handler = SIG_DFL;
707            if (sigaction(SIGHUP, &act, NULL) == -1)
708            {
709                    log_error("set signal action of SIGHUP error: %d\n", errno);
710            }
711            act.sa_handler = SIG_DFL;
712          if (sigaction(SIGCHLD, &act, NULL) == -1)          if (sigaction(SIGCHLD, &act, NULL) == -1)
713          {          {
714                  log_error("set signal action of SIGCHLD error: %d\n", errno);                  log_error("set signal action of SIGCHLD error: %d\n", errno);
715          }          }
716    
         // Force reload to load gen_ex_menu  
         SYS_section_list_reload = 1;  
   
717          // Do section data loader periodically          // Do section data loader periodically
718          while (!SYS_server_exit)          while (!SYS_server_exit)
719          {          {
720                  if (SYS_section_list_reload)                  if (SYS_conf_reload)
721                  {                  {
722                          SYS_section_list_reload = 0;                          SYS_conf_reload = 0;
723    
724                          // Load section config                          // Load section config
725                          if (load_section_config_from_db(1) < 0)                          if (load_section_config_from_db(0) < 0)
726                          {                          {
727                                  log_error("load_section_config_from_db() error\n");                                  log_error("load_section_config_from_db(0) error\n");
728                          }                          }
729                          else                          else
730                          {                          {
# Line 743  int section_list_loader_launch(void) Line 745  int section_list_loader_launch(void)
745    
746                                  if (ret == ERR_UNKNOWN_SECTION)                                  if (ret == ERR_UNKNOWN_SECTION)
747                                  {                                  {
748                                          SYS_section_list_reload = 1; // Force reload section_list                                          SYS_conf_reload = 1; // Force reload section_list
749                                  }                                  }
750                          }                          }
751                  } while (ret == LOAD_ARTICLE_COUNT_LIMIT);                  } while (ret == LOAD_ARTICLE_COUNT_LIMIT);
# Line 754  int section_list_loader_launch(void) Line 756  int section_list_loader_launch(void)
756                          log_common("Incrementally load %d articles, last_aid = %d\n", load_count, article_block_last_aid());                          log_common("Incrementally load %d articles, last_aid = %d\n", load_count, article_block_last_aid());
757                  }                  }
758    
759                  if (SYS_section_list_reload)                  if (SYS_conf_reload)
760                  {                  {
761                          continue;                          continue;
762                  }                  }
# Line 770  int section_list_loader_launch(void) Line 772  int section_list_loader_launch(void)
772    
773                                  if (ret == ERR_UNKNOWN_SECTION)                                  if (ret == ERR_UNKNOWN_SECTION)
774                                  {                                  {
775                                          SYS_section_list_reload = 1; // Force reload section_list                                          SYS_conf_reload = 1; // Force reload section_list
776                                  }                                  }
777                          }                          }
778                  } while (ret == LOAD_ARTICLE_COUNT_LIMIT);                  } while (ret == LOAD_ARTICLE_COUNT_LIMIT);
# Line 780  int section_list_loader_launch(void) Line 782  int section_list_loader_launch(void)
782                          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);
783                  }                  }
784    
785                  if (SYS_section_list_reload)                  if (SYS_conf_reload)
786                  {                  {
787                          continue;                          continue;
788                  }                  }
789    
790                  for (i = 0; i < BBS_section_list_load_interval && !SYS_server_exit && !SYS_section_list_reload; i++)                  for (i = 0; i < BBS_section_list_load_interval && !SYS_server_exit && !SYS_conf_reload; i++)
791                  {                  {
792                          sleep(1);                          sleep(1);
793                  }                  }
# Line 797  int section_list_loader_launch(void) Line 799  int section_list_loader_launch(void)
799    
800          // gen_ex_menu cleanup          // gen_ex_menu cleanup
801          section_list_ex_menu_set_cleanup();          section_list_ex_menu_set_cleanup();
802            
803          // Detach data pools shm          // Detach data pools shm
804          detach_section_list_shm();          detach_section_list_shm();
805          detach_article_block_shm();          detach_article_block_shm();
# Line 812  int section_list_loader_launch(void) Line 814  int section_list_loader_launch(void)
814    
815          return 0;          return 0;
816  }  }
   
 int section_list_loader_reload(void)  
 {  
         if (section_list_loader_pid == 0)  
         {  
                 log_error("section_list_loader not running\n");  
                 return -2;  
         }  
   
         if (kill(section_list_loader_pid, SIGHUP) < 0)  
         {  
                 log_error("Send SIGTERM signal failed (%d)\n", errno);  
                 return -1;  
         }  
   
         return 0;  
 }  
817    
818  int query_section_articles(SECTION_LIST *p_section, int page_id, ARTICLE *p_articles[],  int query_section_articles(SECTION_LIST *p_section, int page_id, ARTICLE *p_articles[],
819                                                     int *p_article_count, int *p_page_count, int *p_ontop_start_offset)                                                     int *p_article_count, int *p_page_count, int *p_ontop_start_offset)


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

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