From: Quanah Gibson-Mount Date: Tue, 2 Jan 2007 22:33:18 +0000 (+0000) Subject: Fix connection_get race condition on Windows X-Git-Tag: OPENLDAP_REL_ENG_2_3_32~16 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=3b63f718e17d271ae2145ecf2ceb8d3791397191;p=openldap Fix connection_get race condition on Windows --- diff --git a/servers/slapd/connection.c b/servers/slapd/connection.c index aecb4252df..8e082cf1c3 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 */