From 622b87d5e84aa3e56d8bcbf3efccc89ce3dae0f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Kuzn=C3=ADk?= Date: Fri, 7 Jul 2017 15:56:32 +0100 Subject: [PATCH] Make ready only when still alive --- servers/lloadd/upstream.c | 87 +++++++++++++++++++++------------------ 1 file changed, 48 insertions(+), 39 deletions(-) diff --git a/servers/lloadd/upstream.c b/servers/lloadd/upstream.c index 9272820441..324de846b3 100644 --- a/servers/lloadd/upstream.c +++ b/servers/lloadd/upstream.c @@ -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 ( 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; } - 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; } + } 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 ( 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; } - 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; } + } else { + assert( c->c_state == SLAP_C_INVALID ); } CONNECTION_UNLOCK_INCREF(c);