From: Howard Chu Date: Thu, 2 Dec 1999 03:21:06 +0000 (+0000) Subject: Don't call FD_SET for an fd if it is already set. This causes major problems X-Git-Tag: UCDATA_2_4~153 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=7eec31c8f622b1dda5a3965b005e8a2ce3ac0095;p=openldap Don't call FD_SET for an fd if it is already set. This causes major problems on NT due to their fd_set implementation. --- diff --git a/servers/slapd/daemon.c b/servers/slapd/daemon.c index 9bd2c9a07f..b88f1e2b9a 100644 --- a/servers/slapd/daemon.c +++ b/servers/slapd/daemon.c @@ -136,7 +136,8 @@ void slapd_set_write(ber_socket_t s, int wake) { ldap_pvt_thread_mutex_lock( &slap_daemon.sd_mutex ); assert( FD_ISSET( s, &slap_daemon.sd_actives) ); - FD_SET( (unsigned) s, &slap_daemon.sd_writers ); + if (!FD_ISSET(s, &slap_daemon.sd_writers)) + FD_SET( (unsigned) s, &slap_daemon.sd_writers ); ldap_pvt_thread_mutex_unlock( &slap_daemon.sd_mutex ); WAKE_LISTENER(wake); @@ -156,7 +157,8 @@ void slapd_set_read(ber_socket_t s, int wake) { ldap_pvt_thread_mutex_lock( &slap_daemon.sd_mutex ); assert( FD_ISSET( s, &slap_daemon.sd_actives) ); - FD_SET( s, &slap_daemon.sd_readers ); + if (!FD_ISSET(s, &slap_daemon.sd_readers)) + FD_SET( s, &slap_daemon.sd_readers ); ldap_pvt_thread_mutex_unlock( &slap_daemon.sd_mutex ); WAKE_LISTENER(wake); @@ -511,12 +513,14 @@ slapd_daemon_task( memcpy( &readfds, &slap_daemon.sd_readers, sizeof(fd_set) ); memcpy( &writefds, &slap_daemon.sd_writers, sizeof(fd_set) ); #endif + assert(!FD_ISSET(wake_sds[0], &readfds)); FD_SET( wake_sds[0], &readfds ); for ( l = 0; slap_listeners[l] != NULL; l++ ) { if ( slap_listeners[l]->sl_sd == AC_SOCKET_INVALID ) continue; - FD_SET( slap_listeners[l]->sl_sd, &readfds ); + if (!FD_ISSET(slap_listeners[l]->sl_sd, &readfds)) + FD_SET( slap_listeners[l]->sl_sd, &readfds ); } #ifndef HAVE_WINSOCK