fixes srvctrl socket shutdown srvctrl

Mon, 06 Mar 2017 17:19:25 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Mon, 06 Mar 2017 17:19:25 +0100
branch
srvctrl
changeset 177
f144b60c71b1
parent 176
f2268fcbe487
child 178
4760f7f1b197

fixes srvctrl socket shutdown

src/server/daemon/srvctrl.c file | annotate | diff | comparison | revisions
--- a/src/server/daemon/srvctrl.c	Mon Mar 06 16:06:00 2017 +0100
+++ b/src/server/daemon/srvctrl.c	Mon Mar 06 17:19:25 2017 +0100
@@ -104,15 +104,12 @@
     for(;;) {
         int fd = accept(srvctrl, NULL, 0);
         if(fd < 0) {
-            if(srv_shutdown) {
-                break;
-            }
-            
+            if(srv_shutdown) break;
             log_ereport(
                     LOG_FAILURE,
                     "srvctrl: accept failed: %s",
                     strerror(errno));
-            continue;
+            break;
         }
         
         SrvCtrlClient *client = srvctrl_create_client(fd);
@@ -125,6 +122,7 @@
         
     }
     
+    close(srvctrl);
     unlink(srvctrl_path.ptr);
     free(srvctrl_path.ptr);
     
@@ -133,7 +131,7 @@
 
 void srvctrl_shutdown() {
     srv_shutdown = TRUE;
-    close(srvctrl);
+    shutdown(srvctrl, SHUT_RDWR);
 }
 
 SrvCtrlClient* srvctrl_create_client(int fd) {
@@ -171,13 +169,11 @@
             break;
         }
     }
-    
     log_remove_logdup(&log);
     
     ucx_buffer_free(line);
     close(client->fd);
     free(client);
-    
     return NULL;
 }
 

mercurial