# HG changeset patch
# User Olaf Wintermann <olaf.wintermann@gmail.com>
# Date 1488817165 -3600
# Node ID f144b60c71b1025ca8bb4d19a9e557f7a13902c4
# Parent  f2268fcbe4877c101167d159c492394132782c3b
fixes srvctrl socket shutdown

diff -r f2268fcbe487 -r f144b60c71b1 src/server/daemon/srvctrl.c
--- 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;
 }