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

Diff of /lbbs/src/net_server.c

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

Revision 1.21 by sysadm, Sat May 10 15:23:42 2025 UTC Revision 1.22 by sysadm, Sun May 11 01:54:00 2025 UTC
# Line 90  int net_server(const char *hostaddr, in_ Line 90  int net_server(const char *hostaddr, in_
90          {          {
91                  sigprocmask(SIG_BLOCK, &nsigset, &osigset);                  sigprocmask(SIG_BLOCK, &nsigset, &osigset);
92    
93                  while (SYS_child_exit_count > 0)                  while ((SYS_child_exit || SYS_server_exit) && SYS_child_process_count > 0)
94                  {                  {
95                          siginfo.si_pid = 0;                          siginfo.si_pid = 0;
96                          ret = waitid(P_ALL, 0, &siginfo, WEXITED | WNOHANG);                          ret = waitid(P_ALL, 0, &siginfo, WEXITED | WNOHANG);
97                          if (ret == 0 && siginfo.si_pid > 0)                          if (ret == 0 && siginfo.si_pid > 0)
98                          {                          {
                                 SYS_child_exit_count--;  
99                                  SYS_child_process_count--;                                  SYS_child_process_count--;
100                                  log_std("Child process (%d) exited\n", siginfo.si_pid);                                  log_std("Child process (%d) exited\n", siginfo.si_pid);
101                          }                          }
102                          else if (ret == 0)                          else if (ret == 0)
103                          {                          {
104                                    SYS_child_exit = 0;
105                                  break;                                  break;
106                          }                          }
107                          else if (ret < 0)                          else if (ret < 0)
# Line 111  int net_server(const char *hostaddr, in_ Line 111  int net_server(const char *hostaddr, in_
111                          }                          }
112                  }                  }
113    
114                  if (SYS_server_exit && SYS_child_exit_count == 0)                  if (SYS_server_exit && !SYS_child_exit && SYS_child_process_count > 0)
115                  {                  {
116                            log_std("Notify %d child process to exit\n", SYS_child_process_count);
117                          if (kill(0, SIGTERM) < 0)                          if (kill(0, SIGTERM) < 0)
118                          {                          {
119                                  log_error("Send SIGTERM signal failed (%d)\n", errno);                                  log_error("Send SIGTERM signal failed (%d)\n", errno);
# Line 136  int net_server(const char *hostaddr, in_ Line 137  int net_server(const char *hostaddr, in_
137    
138                  FD_ZERO(&testfds);                  FD_ZERO(&testfds);
139                  FD_SET(socket_server, &testfds);                  FD_SET(socket_server, &testfds);
140            
141                  timeout.tv_sec = 0;                  timeout.tv_sec = 0;
142                  timeout.tv_usec = 100 * 1000; // 0.1 second                  timeout.tv_usec = 100 * 1000; // 0.1 second
143            
144                  ret = select(FD_SETSIZE, &testfds, NULL, NULL, &timeout);                  ret = select(FD_SETSIZE, &testfds, NULL, NULL, &timeout);
145    
146                  if (ret < 0)                  if (ret < 0)


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

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