]> git.sur5r.net Git - openldap/commitdiff
Fix connection_get race condition on Windows
authorHoward Chu <hyc@openldap.org>
Tue, 26 Dec 2006 23:40:00 +0000 (23:40 +0000)
committerHoward Chu <hyc@openldap.org>
Tue, 26 Dec 2006 23:40:00 +0000 (23:40 +0000)
servers/slapd/connection.c

index c64ef4866ed2ffadf5d3398636c49ac6894fdbc3..40dbb8f62e362fb92add97d499fb19e43a55944f 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 */