]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
Make ready only when still alive
authorOndřej Kuzník <ondra@mistotebe.net>
Fri, 7 Jul 2017 14:56:32 +0000 (15:56 +0100)
committerOndřej Kuzník <okuznik@symas.com>
Tue, 17 Nov 2020 17:55:46 +0000 (17:55 +0000)
servers/lloadd/upstream.c

index 9272820441845cd1256a677ea5a287b5a7be6ed5..324de846b3da0429696a89f7248eb2c430147ca8 100644 (file)
@@ -123,26 +123,30 @@ handle_bind_response( Operation *op, BerElement *ber )
     CONNECTION_UNLOCK(upstream);
 
     CONNECTION_LOCK(client);
-    switch ( result ) {
-        case LDAP_SASL_BIND_IN_PROGRESS:
-            break;
-        case LDAP_SUCCESS:
-        default: {
-            client->c_state = SLAP_C_READY;
-            client->c_type = SLAP_C_OPEN;
-            if ( result != LDAP_SUCCESS ) {
-                ber_memfree( client->c_auth.bv_val );
-                BER_BVZERO( &client->c_auth );
-            } else if ( !ber_bvstrcasecmp(
-                                &client->c_auth, &lloadd_identity ) ) {
-                client->c_type = SLAP_C_PRIVILEGED;
-            }
-            if ( !BER_BVISNULL( &client->c_sasl_bind_mech ) ) {
-                ber_memfree( client->c_sasl_bind_mech.bv_val );
-                BER_BVZERO( &client->c_sasl_bind_mech );
+    if ( client->c_state == SLAP_C_BINDING ) {
+        switch ( result ) {
+            case LDAP_SASL_BIND_IN_PROGRESS:
+                break;
+            case LDAP_SUCCESS:
+            default: {
+                client->c_state = SLAP_C_READY;
+                client->c_type = SLAP_C_OPEN;
+                if ( result != LDAP_SUCCESS ) {
+                    ber_memfree( client->c_auth.bv_val );
+                    BER_BVZERO( &client->c_auth );
+                } else if ( !ber_bvstrcasecmp(
+                                    &client->c_auth, &lloadd_identity ) ) {
+                    client->c_type = SLAP_C_PRIVILEGED;
+                }
+                if ( !BER_BVISNULL( &client->c_sasl_bind_mech ) ) {
+                    ber_memfree( client->c_sasl_bind_mech.bv_val );
+                    BER_BVZERO( &client->c_sasl_bind_mech );
+                }
+                break;
             }
-            break;
         }
+    } else {
+        assert( client->c_state == SLAP_C_INVALID );
     }
     CONNECTION_UNLOCK(client);
 
@@ -227,29 +231,34 @@ handle_vc_bind_response( Operation *op, BerElement *ber )
         }
     }
 
-    switch ( result ) {
-        case LDAP_SASL_BIND_IN_PROGRESS:
-            break;
-        case LDAP_SUCCESS:
-        default: {
-            c->c_state = SLAP_C_READY;
-            c->c_type = SLAP_C_OPEN;
-            if ( result != LDAP_SUCCESS ) {
-                ber_memfree( c->c_auth.bv_val );
-                BER_BVZERO( &c->c_auth );
-            } else if ( !ber_bvstrcasecmp( &c->c_auth, &lloadd_identity ) ) {
-                c->c_type = SLAP_C_PRIVILEGED;
-            }
-            if ( !BER_BVISNULL( &c->c_vc_cookie ) ) {
-                ber_memfree( c->c_vc_cookie.bv_val );
-                BER_BVZERO( &c->c_vc_cookie );
-            }
-            if ( !BER_BVISNULL( &c->c_sasl_bind_mech ) ) {
-                ber_memfree( c->c_sasl_bind_mech.bv_val );
-                BER_BVZERO( &c->c_sasl_bind_mech );
+    if ( c->c_state == SLAP_C_BINDING ) {
+        switch ( result ) {
+            case LDAP_SASL_BIND_IN_PROGRESS:
+                break;
+            case LDAP_SUCCESS:
+            default: {
+                c->c_state = SLAP_C_READY;
+                c->c_type = SLAP_C_OPEN;
+                if ( result != LDAP_SUCCESS ) {
+                    ber_memfree( c->c_auth.bv_val );
+                    BER_BVZERO( &c->c_auth );
+                } else if ( !ber_bvstrcasecmp(
+                                    &c->c_auth, &lloadd_identity ) ) {
+                    c->c_type = SLAP_C_PRIVILEGED;
+                }
+                if ( !BER_BVISNULL( &c->c_vc_cookie ) ) {
+                    ber_memfree( c->c_vc_cookie.bv_val );
+                    BER_BVZERO( &c->c_vc_cookie );
+                }
+                if ( !BER_BVISNULL( &c->c_sasl_bind_mech ) ) {
+                    ber_memfree( c->c_sasl_bind_mech.bv_val );
+                    BER_BVZERO( &c->c_sasl_bind_mech );
+                }
+                break;
             }
-            break;
         }
+    } else {
+        assert( c->c_state == SLAP_C_INVALID );
     }
     CONNECTION_UNLOCK_INCREF(c);