]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/connection.c
Fix connection_get race condition on Windows
[openldap] / servers / slapd / connection.c
index aecb4252df966c6ddef603ed22b63872db4a3776..8e082cf1c310ea91ddded64bc0bd2254fe0a768a 100644 (file)
@@ -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 */