/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
- * Copyright 1998-2007 The OpenLDAP Foundation.
+ * Copyright 1998-2009 The OpenLDAP Foundation.
* Portions Copyright 2007 by Howard Chu, Symas Corporation.
* All rights reserved.
*
#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;
{
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--;
}
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 && wake_sds[1] != wake_sds[0] )
+#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
Debug( LDAP_DEBUG_ANY,
"daemon: "
SLAP_EVENT_FNAME
- "failed count %d "
+ " failed count %d "
"err (%d): %s\n",
ebadf, err,
sock_errstr( err ) );
#endif /* LDAP_DEBUG */
for ( i = 0; i < ns; i++ ) {
- int rc = 1, fd;
+ int rc = 1, fd, w = 0;
if ( SLAP_EVENT_IS_LISTENER( i ) ) {
rc = slap_listener_activate( SLAP_EVENT_LISTENER( i ) );
char c[BUFSIZ];
waking = 0;
tcp_read( SLAP_FD2SOCK(wake_sds[0]), c, sizeof(c) );
- break;
+ continue;
}
if ( SLAP_EVENT_IS_WRITE( i ) ) {
fd, 0, 0 );
SLAP_EVENT_CLR_WRITE( i );
+ w = 1;
/*
* NOTE: it is possible that the connection was closed
SLAP_EVENT_CLR_READ( i );
connection_read_activate( fd );
- } else {
+ } else if ( !w ) {
Debug( LDAP_DEBUG_CONNS,
"daemon: hangup on %d\n", fd, 0, 0 );
+ if ( SLAP_SOCK_IS_ACTIVE( fd )) {
+#ifdef HAVE_EPOLL
+ /* Don't keep reporting the hangup
+ */
+ SLAP_EPOLL_SOCK_SET( fd, EPOLLET );
+#endif
+ connection_hangup( fd );
+ }
}
}
}
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 );
{
int rc;
- connections_init();
#ifdef LDAP_CONNECTIONLESS
connectionless_init();
#endif /* LDAP_CONNECTIONLESS */