]> code.citadel.org Git - citadel.git/blobdiff - citadel/context.c
just log the close if we're realy going to close.
[citadel.git] / citadel / context.c
index dce6841c0aa450aaa15d0cf3249073b29e2ee8c6..fbb3272de460ffac9d503340181c67ad1eadc3fe 100644 (file)
@@ -350,9 +350,15 @@ void RemoveContext (CitContext *con)
 
        CtdlLogPrintf(CTDL_NOTICE, "[%3d] Session ended.\n", con->cs_pid);
 
-       /* If the client is still connected, blow 'em away. */
-       CtdlLogPrintf(CTDL_DEBUG, "Closing socket %d\n", con->client_socket);
-       close(con->client_socket);
+       /* 
+        * If the client is still connected, blow 'em away. 
+        * if the socket is 0, its already gone or was never there.
+        */
+       if (con->client_socket != 0)
+       {
+               CtdlLogPrintf(CTDL_DEBUG, "Closing socket %d\n", con->client_socket);
+               close(con->client_socket);
+       }
 
        /* If using AUTHMODE_LDAP, free the DN */
        if (con->ldap_dn) {