]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/daemon.c
fix previous commit (ITS#5819)
[openldap] / servers / slapd / daemon.c
index d68c4bd79ca1417f2790aea8ea7a536bee87461f..f5555d6a18e92c8e329f3eb1986e41aa8cb1e512 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2007 The OpenLDAP Foundation.
+ * Copyright 1998-2008 The OpenLDAP Foundation.
  * Portions Copyright 2007 by Howard Chu, Symas Corporation.
  * All rights reserved.
  *
@@ -79,7 +79,11 @@ Listener **slap_listeners = NULL;
 #define SLAPD_LISTEN_BACKLOG 1024
 #endif /* ! SLAPD_LISTEN_BACKLOG */
 
-static ber_socket_t wake_sds[2];
+static ber_socket_t wake_sds[2]
+#ifdef HAVE_WINSOCK
+       = { INVALID_SOCKET, INVALID_SOCKET }
+#endif /* HAVE_WINSOCK */
+       ;
 static int emfile;
 
 static volatile int waking;
@@ -928,9 +932,9 @@ slapd_clr_write( ber_socket_t s, int wake )
 {
        ldap_pvt_thread_mutex_lock( &slap_daemon.sd_mutex );
 
-       assert( SLAP_SOCK_IS_ACTIVE( s ));
-
        if ( SLAP_SOCK_IS_WRITE( s )) {
+               assert( SLAP_SOCK_IS_ACTIVE( s ));
+
                SLAP_SOCK_CLR_WRITE( s );
                slap_daemon.sd_nwriters--;
        }
@@ -1641,8 +1645,14 @@ int
 slapd_daemon_destroy( void )
 {
        connections_destroy();
-       tcp_close( SLAP_FD2SOCK(wake_sds[1]) );
-       tcp_close( SLAP_FD2SOCK(wake_sds[0]) );
+#ifdef HAVE_WINSOCK
+       if ( wake_sds[1] != INVALID_SOCKET )
+#endif /* HAVE_WINSOCK */
+               tcp_close( SLAP_FD2SOCK(wake_sds[1]) );
+#ifdef HAVE_WINSOCK
+       if ( wake_sds[0] != INVALID_SOCKET )
+#endif /* HAVE_WINSOCK */
+               tcp_close( SLAP_FD2SOCK(wake_sds[0]) );
        sockdestroy();
 
 #ifdef HAVE_SLP
@@ -2291,7 +2301,7 @@ slapd_daemon_task(
                                                Debug( LDAP_DEBUG_ANY,
                                                        "daemon: "
                                                        SLAP_EVENT_FNAME
-                                                       "failed count %d "
+                                                       " failed count %d "
                                                        "err (%d): %s\n",
                                                        ebadf, err,
                                                        sock_errstr( err ) );
@@ -2572,9 +2582,12 @@ slapd_daemon_task(
                connections_shutdown();
        }
 
-       Debug( LDAP_DEBUG_ANY,
-               "slapd shutdown: waiting for %d threads to terminate\n",
-               ldap_pvt_thread_pool_backload( &connection_pool ), 0, 0 );
+       if ( LogTest( LDAP_DEBUG_ANY )) {
+               int t = ldap_pvt_thread_pool_backload( &connection_pool );
+               Debug( LDAP_DEBUG_ANY,
+                       "slapd shutdown: waiting for %d operations/tasks to finish\n",
+                       t, 0, 0 );
+       }
        ldap_pvt_thread_pool_destroy( &connection_pool, 1 );
 
        free( slap_listeners );
@@ -2620,7 +2633,6 @@ slapd_daemon( void )
 {
        int rc;
 
-       connections_init();
 #ifdef LDAP_CONNECTIONLESS
        connectionless_init();
 #endif /* LDAP_CONNECTIONLESS */