| 446 |
|
|
| 447 |
SYS_child_process_count = 0; |
SYS_child_process_count = 0; |
| 448 |
|
|
| 449 |
|
// BWF compile |
| 450 |
|
if (bwf_compile() < 0) |
| 451 |
|
{ |
| 452 |
|
log_error("bwf_compile() error\n"); |
| 453 |
|
goto cleanup; |
| 454 |
|
} |
| 455 |
|
|
| 456 |
bbs_main(); |
bbs_main(); |
| 457 |
|
|
| 458 |
cleanup: |
cleanup: |
| 489 |
ssh_free(SSH_session); |
ssh_free(SSH_session); |
| 490 |
ssh_finalize(); |
ssh_finalize(); |
| 491 |
|
|
| 492 |
|
// BWF cleanup |
| 493 |
|
bwf_cleanup(); |
| 494 |
|
|
| 495 |
// Close Input and Output for client |
// Close Input and Output for client |
| 496 |
io_cleanup(); |
io_cleanup(); |
| 497 |
close(STDIN_FILENO); |
close(STDIN_FILENO); |
| 521 |
int nfds; |
int nfds; |
| 522 |
int notify_child_exit = 0; |
int notify_child_exit = 0; |
| 523 |
time_t tm_notify_child_exit = time(NULL); |
time_t tm_notify_child_exit = time(NULL); |
|
MENU_SET bbs_menu_new; |
|
|
MENU_SET top10_menu_new; |
|
| 524 |
int i, j; |
int i, j; |
| 525 |
pid_t pid; |
pid_t pid; |
| 526 |
int ssh_log_level = SSH_LOG_NOLOG; |
int ssh_log_level = SSH_LOG_NOLOG; |
| 649 |
{ |
{ |
| 650 |
SYS_child_exit = 0; |
SYS_child_exit = 0; |
| 651 |
|
|
| 652 |
pid = waitpid(-1, NULL, WNOHANG); |
pid = waitpid(-1, &ret, WNOHANG); |
| 653 |
if (pid > 0) |
if (pid > 0) |
| 654 |
{ |
{ |
| 655 |
SYS_child_exit = 1; // Retry waitid |
SYS_child_exit = 1; // Retry waitid |
|
|
|
| 656 |
SYS_child_process_count--; |
SYS_child_process_count--; |
| 657 |
log_common("Child process (%d) exited\n", pid); |
|
| 658 |
|
if (WIFEXITED(ret)) |
| 659 |
|
{ |
| 660 |
|
log_common("Child process (%d) exited, status=%d\n", pid, WEXITSTATUS(ret)); |
| 661 |
|
} |
| 662 |
|
else if (WIFSIGNALED(ret)) |
| 663 |
|
{ |
| 664 |
|
log_common("Child process (%d) is killed, status=%d\n", pid, WTERMSIG(ret)); |
| 665 |
|
} |
| 666 |
|
else |
| 667 |
|
{ |
| 668 |
|
log_common("Child process (%d) exited abnormally, status=%d\n", pid, ret); |
| 669 |
|
} |
| 670 |
|
|
| 671 |
if (pid != section_list_loader_pid) |
if (pid != section_list_loader_pid) |
| 672 |
{ |
{ |
| 712 |
log_common("Notify %d child process to exit\n", SYS_child_process_count); |
log_common("Notify %d child process to exit\n", SYS_child_process_count); |
| 713 |
#endif |
#endif |
| 714 |
|
|
| 715 |
if (kill(-getpid(), SIGTERM) < 0) |
if (kill(0, SIGTERM) < 0) |
| 716 |
{ |
{ |
| 717 |
log_error("Send SIGTERM signal failed (%d)\n", errno); |
log_error("Send SIGTERM signal failed (%d)\n", errno); |
| 718 |
} |
} |
| 726 |
sd_notifyf(0, "STATUS=Kill %d child process", SYS_child_process_count); |
sd_notifyf(0, "STATUS=Kill %d child process", SYS_child_process_count); |
| 727 |
#endif |
#endif |
| 728 |
|
|
| 729 |
if (kill(-getpid(), SIGKILL) < 0) |
if (kill(0, SIGKILL) < 0) |
| 730 |
{ |
{ |
| 731 |
log_error("Send SIGKILL signal failed (%d)\n", errno); |
log_error("Send SIGKILL signal failed (%d)\n", errno); |
| 732 |
} |
} |
| 767 |
log_error("Reload BWF conf failed\n"); |
log_error("Reload BWF conf failed\n"); |
| 768 |
} |
} |
| 769 |
|
|
| 770 |
if (load_menu(&bbs_menu_new, CONF_MENU) < 0) |
if (detach_menu_shm(&bbs_menu) < 0) |
| 771 |
{ |
{ |
| 772 |
unload_menu(&bbs_menu_new); |
log_error("detach_menu_shm(bbs_menu) error\n"); |
|
log_error("Reload bbs menu failed\n"); |
|
| 773 |
} |
} |
| 774 |
else |
if (load_menu(&bbs_menu, CONF_MENU) < 0) |
| 775 |
{ |
{ |
| 776 |
|
log_error("load_menu(bbs_menu) error\n"); |
| 777 |
unload_menu(&bbs_menu); |
unload_menu(&bbs_menu); |
|
memcpy(&bbs_menu, &bbs_menu_new, sizeof(bbs_menu_new)); |
|
|
log_common("Reload bbs menu successfully\n"); |
|
| 778 |
} |
} |
| 779 |
|
|
| 780 |
if (load_menu(&top10_menu_new, CONF_TOP10_MENU) < 0) |
if (detach_menu_shm(&top10_menu) < 0) |
| 781 |
{ |
{ |
| 782 |
unload_menu(&top10_menu_new); |
log_error("detach_menu_shm(top10_menu) error\n"); |
|
log_error("Reload top10 menu failed\n"); |
|
| 783 |
} |
} |
| 784 |
else |
if (load_menu(&top10_menu, CONF_TOP10_MENU) < 0) |
| 785 |
{ |
{ |
| 786 |
|
log_error("load_menu(top10_menu) error\n"); |
| 787 |
unload_menu(&top10_menu); |
unload_menu(&top10_menu); |
|
top10_menu_new.allow_exit = 1; |
|
|
memcpy(&top10_menu, &top10_menu_new, sizeof(top10_menu_new)); |
|
|
log_common("Reload top10 menu successfully\n"); |
|
| 788 |
} |
} |
| 789 |
|
|
| 790 |
for (int i = 0; i < data_files_load_startup_count; i++) |
for (int i = 0; i < data_files_load_startup_count; i++) |
| 794 |
log_error("load_file(%s) error\n", data_files_load_startup[i]); |
log_error("load_file(%s) error\n", data_files_load_startup[i]); |
| 795 |
} |
} |
| 796 |
} |
} |
|
log_common("Reload data files successfully\n"); |
|
| 797 |
|
|
| 798 |
// Load section config and gen_ex |
// Load section config and gen_ex |
| 799 |
if (load_section_config_from_db(1) < 0) |
if (load_section_config_from_db(1) < 0) |
| 800 |
{ |
{ |
| 801 |
log_error("load_section_config_from_db(1) error\n"); |
log_error("load_section_config_from_db(1) error\n"); |
| 802 |
} |
} |
|
else |
|
|
{ |
|
|
log_common("Reload section config and gen_ex successfully\n"); |
|
|
} |
|
| 803 |
|
|
| 804 |
// Notify child processes to reload configuration |
// Notify child processes to reload configuration |
| 805 |
if (kill(-getpid(), SIGUSR1) < 0) |
if (kill(0, SIGUSR1) < 0) |
| 806 |
{ |
{ |
| 807 |
log_error("Send SIGUSR1 signal failed (%d)\n", errno); |
log_error("Send SIGUSR1 signal failed (%d)\n", errno); |
| 808 |
} |
} |