]> git.sur5r.net Git - openldap/commitdiff
Resched changes struct state without lock to avoid deadlock.
authorKurt Zeilenga <kurt@openldap.org>
Sat, 12 Jun 1999 00:29:41 +0000 (00:29 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Sat, 12 Jun 1999 00:29:41 +0000 (00:29 +0000)
Hence connection_get must recheck struct state after obtaining
c_mutex to detect close.

servers/slapd/connection.c

index 1a78ba46ba7e391d996fec063b362a087b67f652..514eae4be9fb07f39dbba0830f5729e45d5c19a5 100644 (file)
@@ -158,14 +158,6 @@ static Connection* connection_get( int s )
 
        assert( c->c_struct_state != SLAP_C_UNINITIALIZED );
 
-       if( c->c_struct_state != SLAP_C_USED ) {
-               /* connection must have been closed */
-               assert( c->c_conn_state == SLAP_C_INVALID );
-               assert( !ber_pvt_sb_in_use( c->c_sb ) );
-
-               return NULL;
-       }
-
 #else
        c = NULL;
        {
@@ -199,7 +191,18 @@ static Connection* connection_get( int s )
        if( c != NULL ) {
                ldap_pvt_thread_mutex_lock( &c->c_mutex );
 
-               /* we do this AFTER locking to aid in debugging */
+               if( c->c_struct_state != SLAP_C_USED ) {
+                       /* connection must have been closed due to resched */
+                       assert( c->c_conn_state == SLAP_C_INVALID );
+                       assert( !ber_pvt_sb_in_use( c->c_sb ) );
+
+                       Debug( LDAP_DEBUG_TRACE,
+                               "connection_get(%d): connection not used.\n",
+                               s, c->c_connid, 0 );
+
+                       return NULL;
+               }
+
                Debug( LDAP_DEBUG_TRACE,
                        "connection_get(%d): got connid=%ld\n",
                        s, c->c_connid, 0 );