From: Kurt Zeilenga Date: Wed, 5 Jul 2000 22:15:43 +0000 (+0000) Subject: Fix error handling X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~2473 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=5c4cef793f26f83ea94d5fa940e7708837633d9f;p=openldap Fix error handling --- diff --git a/servers/slapd/bind.c b/servers/slapd/bind.c index 91fe758961..8239c9c3ef 100644 --- a/servers/slapd/bind.c +++ b/servers/slapd/bind.c @@ -216,19 +216,28 @@ do_bind( ldap_pvt_thread_mutex_lock( &conn->c_mutex ); if ( conn->c_sasl_bind_mech != NULL ) { + /* SASL bind is in progress */ +#ifdef HAVE_CYRUS_SASL + assert( conn->c_sasl_bind_context != NULL ); +#endif + if((strcmp(conn->c_sasl_bind_mech, mech) != 0)) { - /* mechanism changed, cancel in progress bind */ + /* mechanism changed */ #ifdef HAVE_CYRUS_SASL + /* dispose of context */ sasl_dispose(&conn->c_sasl_bind_context); conn->c_sasl_bind_context = NULL; #endif } + free( conn->c_sasl_bind_mech ); conn->c_sasl_bind_mech = NULL; #ifdef LDAP_DEBUG -#ifdef HAVE_CYRUS_SASL } else { + /* SASL bind is NOT in progress */ + assert( conn->c_sasl_bind_mech == NULL ); +#ifdef HAVE_CYRUS_SASL assert( conn->c_sasl_bind_context == NULL ); #endif #endif @@ -256,7 +265,7 @@ do_bind( #ifdef HAVE_CYRUS_SASL } else { - assert( conn->c_sasl_bind_context != NULL ); + assert( conn->c_sasl_bind_context == NULL ); #endif } @@ -374,6 +383,24 @@ do_bind( } cleanup: + if( rc != LDAP_SASL_BIND_IN_PROGRESS ) { + ldap_pvt_thread_mutex_lock( &conn->c_mutex ); + + /* dispose of mech */ + free( conn->c_sasl_bind_mech ); + conn->c_sasl_bind_mech = NULL; + +#ifdef HAVE_CYRUS_SASL + if( conn->c_sasl_bind_context != NULL ) { + /* dispose of context */ + sasl_dispose(&conn->c_sasl_bind_context); + conn->c_sasl_bind_context = NULL; + } +#endif + + ldap_pvt_thread_mutex_unlock( &conn->c_mutex ); + } + if( dn != NULL ) { free( dn ); }