[Date Prev][Date Next] [Chronological] [Thread] [Top]

(ITS#5855) slapd crash at hang or shutdown

Full_Name: Carl Traub
Version: all ?
OS: Windows
URL: ftp://ftp.openldap.org/incoming/
Submission from: (NULL) (

On Windows,I have found that by simply starting slapd, waiting a few minutes for
it to get fully loaded, and then hitting Ctrl-C, slapd will often hang and not
terminate properly.  It occasionally crashed, and that may been related.

The problem is that in slapd_daemon_destroy(), tcp_close() was being called for
both wake_sds[1] and wake_sds[0], and the 2 values were always the same.  This
meant that Windows was being asked to close a connection that had already been
closed and was no longer valid.

A coworker stated that on Windows, these 2 values are always the same, but he
thought that on Unix they would always be different.

I uploaded the diff file "carlTraub-121208.diff".  I wasn't clear on using the
diff tool.

Below is the diff.

--- P:\temp\daemon.c_bef	Fri Dec 12 10:05:38 2008
+++ P:\temp\daemon.c_after	Fri Dec 12 10:24:30 2008
@@ -1645,14 +1645,10 @@
 slapd_daemon_destroy( void )
+    // If the 2 connections are actually the same, closing it twice can cause
bad things, like hangs or crashes.
+    // It may be that they are always the same on Windows, always different on
+    if (wake_sds[1] != wake_sds[0] ) {	
+	    if ( wake_sds[1] != INVALID_SOCKET )
-	if ( wake_sds[1] != INVALID_SOCKET )
 #endif /* HAVE_WINSOCK */
+		    tcp_close( SLAP_FD2SOCK(wake_sds[1]) );
+	}
-		tcp_close( SLAP_FD2SOCK(wake_sds[1]) );
 	if ( wake_sds[0] != INVALID_SOCKET )
 #endif /* HAVE_WINSOCK */