/[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.30 by sysadm, Tue May 13 07:30:53 2025 UTC Revision 1.31 by sysadm, Tue May 13 10:42:21 2025 UTC
# Line 35  Line 35 
35  #include <sys/wait.h>  #include <sys/wait.h>
36  #include <sys/epoll.h>  #include <sys/epoll.h>
37  #include <arpa/inet.h>  #include <arpa/inet.h>
38    #include <systemd/sd-daemon.h>
39    
40  int net_server(const char *hostaddr, in_port_t port)  int net_server(const char *hostaddr, in_port_t port)
41  {  {
# Line 45  int net_server(const char *hostaddr, in_ Line 46  int net_server(const char *hostaddr, in_
46          struct epoll_event ev, events[MAX_EVENTS];          struct epoll_event ev, events[MAX_EVENTS];
47          int nfds, epollfd;          int nfds, epollfd;
48          siginfo_t siginfo;          siginfo_t siginfo;
49            int sd_notify_stopping = 0;
50    
51          socket_server = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);          socket_server = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
52    
# Line 112  int net_server(const char *hostaddr, in_ Line 114  int net_server(const char *hostaddr, in_
114          flags = fcntl(socket_server, F_GETFL, 0);          flags = fcntl(socket_server, F_GETFL, 0);
115          fcntl(socket_server, F_SETFL, flags | O_NONBLOCK);          fcntl(socket_server, F_SETFL, flags | O_NONBLOCK);
116    
117            // Startup complete
118            sd_notifyf(0, "READY=1\n"
119                                      "STATUS=Accepting incoming connections...\n"
120                                      "MAINPID=%d",
121                               getpid());
122    
123          while (!SYS_server_exit || SYS_child_process_count > 0)          while (!SYS_server_exit || SYS_child_process_count > 0)
124          {          {
125                    if (SYS_server_exit && !sd_notify_stopping)
126                    {
127                            sd_notify(0, "STOPPING=1");
128                            sd_notify_stopping = 1;
129                    }
130                  while ((SYS_child_exit || SYS_server_exit) && SYS_child_process_count > 0)                  while ((SYS_child_exit || SYS_server_exit) && SYS_child_process_count > 0)
131                  {                  {
132                          SYS_child_exit = 0;                          SYS_child_exit = 0;
# Line 145  int net_server(const char *hostaddr, in_ Line 158  int net_server(const char *hostaddr, in_
158                          {                          {
159                                  log_error("Send SIGTERM signal failed (%d)\n", errno);                                  log_error("Send SIGTERM signal failed (%d)\n", errno);
160                          }                          }
161    
162                            sd_notifyf(0, "STATUS=Waiting for %d child process to exit", SYS_child_process_count);
163                  }                  }
164    
165                  if (SYS_menu_reload && !SYS_server_exit)                  if (SYS_menu_reload && !SYS_server_exit)


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

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