]> git.sur5r.net Git - openldap/commitdiff
Fix error handling
authorKurt Zeilenga <kurt@openldap.org>
Wed, 5 Jul 2000 22:15:43 +0000 (22:15 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Wed, 5 Jul 2000 22:15:43 +0000 (22:15 +0000)
servers/slapd/bind.c

index 91fe75896155b8bc55f4ab4cd8a32395d5bcebc7..8239c9c3ef726f7e165de84d4f8cb24802065698 100644 (file)
@@ -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 );
        }