From 5b218b76718546e5ef0172b4e811b933b66ac434 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Fri, 4 Jun 1999 01:05:29 +0000 Subject: [PATCH] Move WAKE_LISTENER call behind &connection_mutex to eliminate race condition on file descriptor sets. --- servers/slapd/daemon.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/servers/slapd/daemon.c b/servers/slapd/daemon.c index 86410a54fc..a0f6a0b11b 100644 --- a/servers/slapd/daemon.c +++ b/servers/slapd/daemon.c @@ -114,46 +114,44 @@ void slapd_remove(int s) { void slapd_clr_write(int s, int wake) { ldap_pvt_thread_mutex_lock( &slap_daemon.sd_mutex ); + WAKE_LISTENER; assert( FD_ISSET( (unsigned) s, &slap_daemon.sd_actives) ); FD_CLR( (unsigned) s, &slap_daemon.sd_writers ); ldap_pvt_thread_mutex_unlock( &slap_daemon.sd_mutex ); - - WAKE_LISTENER; } void slapd_set_write(int s, int wake) { ldap_pvt_thread_mutex_lock( &slap_daemon.sd_mutex ); + WAKE_LISTENER; + assert( FD_ISSET( s, &slap_daemon.sd_actives) ); FD_SET( (unsigned) s, &slap_daemon.sd_writers ); ldap_pvt_thread_mutex_unlock( &slap_daemon.sd_mutex ); - - WAKE_LISTENER; } void slapd_clr_read(int s, int wake) { ldap_pvt_thread_mutex_lock( &slap_daemon.sd_mutex ); + WAKE_LISTENER; assert( FD_ISSET( s, &slap_daemon.sd_actives) ); FD_CLR( (unsigned) s, &slap_daemon.sd_readers ); ldap_pvt_thread_mutex_unlock( &slap_daemon.sd_mutex ); - WAKE_LISTENER; } void slapd_set_read(int s, int wake) { ldap_pvt_thread_mutex_lock( &slap_daemon.sd_mutex ); + WAKE_LISTENER; assert( FD_ISSET( s, &slap_daemon.sd_actives) ); FD_SET( (unsigned) s, &slap_daemon.sd_readers ); ldap_pvt_thread_mutex_unlock( &slap_daemon.sd_mutex ); - - WAKE_LISTENER; } static void slapd_close(int s) { -- 2.39.5