Sockets: make clear we don't close a socket again.
authorWilfried Goesgens <dothebart@citadel.org>
Tue, 16 Apr 2013 19:42:24 +0000 (21:42 +0200)
committerWilfried Goesgens <dothebart@citadel.org>
Tue, 16 Apr 2013 19:42:24 +0000 (21:42 +0200)
citadel/sysdep.c

index 6bdbac3e74c8402846a39331361abe962a118834..193458d5667de921c4d0ead5b8cff7967c7823a8 100644 (file)
@@ -917,18 +917,39 @@ void close_masters (void)
 
                if (serviceptr->tcp_port > 0)
                {
-                       syslog(LOG_INFO, "Closing %d listener on port %d\n",
+                       const char *Text;
+
+                       if (serviceptr->msock == -1)
+                               Text = "not closing again";
+                       else
+                               Text = "Closing";
+                                       
+                       syslog(LOG_INFO, "%s %d listener on port %d\n",
+                              Text,
                               serviceptr->msock,
                               serviceptr->tcp_port);
                        serviceptr->tcp_port = 0;
                }
                
                if (serviceptr->sockpath != NULL)
-                       syslog(LOG_INFO, "Closing %d listener on '%s'\n",
+               {
+                       if (serviceptr->msock == -1)
+                               Text = "not closing again";
+                       else
+                               Text = "Closing";
+
+                       syslog(LOG_INFO, "%s %d listener on '%s'\n",
+                              Text,
                               serviceptr->msock,
                               serviceptr->sockpath);
+               }
+
                 if (serviceptr->msock != -1)
+               {
                        close(serviceptr->msock);
+                       serviceptr->msock = -1;
+               }
+
                /* If it's a Unix domain socket, remove the file. */
                if (serviceptr->sockpath != NULL) {
                        unlink(serviceptr->sockpath);