From d2fc667fe7711aa78284caa040724141233b0c57 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Tue, 26 Dec 2006 23:40:00 +0000 Subject: [PATCH] Fix connection_get race condition on Windows --- servers/slapd/connection.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/servers/slapd/connection.c b/servers/slapd/connection.c index c64ef4866e..40dbb8f62e 100644 --- a/servers/slapd/connection.c +++ b/servers/slapd/connection.c @@ -310,6 +310,15 @@ static Connection* connection_get( ber_socket_t s ) assert( c->c_struct_state != SLAP_C_UNINITIALIZED ); ber_sockbuf_ctrl( c->c_sb, LBER_SB_OPT_GET_FD, &sd ); +#ifdef HAVE_WINSOCK + /* Avoid race condition after releasing + * connections_mutex + */ + if ( sd != s ) { + ldap_pvt_thread_mutex_unlock( &c->c_mutex ); + return NULL; + } +#endif if( c->c_struct_state != SLAP_C_USED ) { /* connection must have been closed due to resched */ -- 2.39.5