]> git.sur5r.net Git - openldap/commitdiff
cleanup resource release
authorPierangelo Masarati <ando@openldap.org>
Sun, 14 May 2006 15:11:53 +0000 (15:11 +0000)
committerPierangelo Masarati <ando@openldap.org>
Sun, 14 May 2006 15:11:53 +0000 (15:11 +0000)
servers/slapd/back-ldap/bind.c
servers/slapd/back-meta/search.c

index 2b0d39bd2557912e64a3553025987cc3c4ee5e91..21b49cf007745fad361581c73286f65cb22cbbd1 100644 (file)
@@ -525,7 +525,7 @@ ldap_back_prepare_conn( ldapconn_t **lcp, Operation *op, SlapReply *rs, ldap_bac
 
        if ( *lcp == NULL ) {
                *lcp = (ldapconn_t *)ch_calloc( 1, sizeof( ldapconn_t ) );
-               (*lcp)->lc_flags= li->li_flags;
+               (*lcp)->lc_flags = li->li_flags;
        }
        (*lcp)->lc_ld = ld;
        (*lcp)->lc_refcnt = 1;
@@ -736,6 +736,7 @@ retry_lock:
                        Debug( LDAP_DEBUG_TRACE,
                                "=>ldap_back_getconn: %s.\n", buf, 0, 0 );
                }
+       
        }
 
 #ifdef HAVE_TLS
@@ -981,6 +982,7 @@ retry:;
                        }
                }
 
+               lc->lc_binding--;
                ldap_back_freeconn( op, lc, dolock );
                rs->sr_err = slap_map_api2result( rs );
 
index bc0010b81f917f1e161d157d15fc99400c976a0d..f599039daf7a1a0c3faf76b6e392b632cfbf5a99 100644 (file)
@@ -93,8 +93,6 @@ meta_search_dobind_init(
                return META_SEARCH_CANDIDATE;
        }
 
-       assert( msc->msc_ld != NULL );
-
        ldap_pvt_thread_mutex_lock( &mi->mi_conninfo.lai_mutex );
        if ( LDAP_BACK_CONN_ISBOUND( msc ) || LDAP_BACK_CONN_ISANON( msc ) ) {
                ldap_pvt_thread_mutex_unlock( &mi->mi_conninfo.lai_mutex );
@@ -133,6 +131,8 @@ meta_search_dobind_init(
        }
 
 retry:;
+       assert( msc->msc_ld != NULL );
+
        rc = ldap_sasl_bind( msc->msc_ld, binddn, LDAP_SASL_SIMPLE, &cred,
                        NULL, NULL, &candidates[ candidate ].sr_msgid );
        switch ( rc ) {
@@ -192,7 +192,9 @@ meta_search_dobind_result(
        meta_search_candidate_t retcode = META_SEARCH_NOT_CANDIDATE;
        int                     rc;
 
-        rc = ldap_parse_result( msc->msc_ld, res,
+       assert( msc->msc_ld != NULL );
+
+       rc = ldap_parse_result( msc->msc_ld, res,
                &candidates[ candidate ].sr_err,
                NULL, NULL, NULL, NULL, 1 );
        if ( rc == LDAP_SUCCESS ) {
@@ -250,7 +252,8 @@ meta_back_search_start(
 
        /* should we check return values? */
        if ( op->ors_deref != -1 ) {
-               ldap_set_option( msc->msc_ld, LDAP_OPT_DEREF,
+               assert( msc->msc_ld != NULL );
+               (void)ldap_set_option( msc->msc_ld, LDAP_OPT_DEREF,
                                ( void * )&op->ors_deref );
        }
 
@@ -1229,11 +1232,9 @@ finish:;
                        continue;
                }
 
-               if ( mc ) {
+               if ( mc && candidates[ i ].sr_msgid >= 0 ) {
                        ldap_pvt_thread_mutex_lock( &mi->mi_conninfo.lai_mutex );
-                       if ( LDAP_BACK_CONN_BINDING( &mc->mc_conns[ i ] )
-                               && candidates[ i ].sr_msgid != META_MSGID_NEED_BIND )
-                       {
+                       if ( LDAP_BACK_CONN_BINDING( &mc->mc_conns[ i ] ) ) {
                                LDAP_BACK_CONN_BINDING_CLEAR( &mc->mc_conns[ i ] );
                        }
                        ldap_pvt_thread_mutex_unlock( &mi->mi_conninfo.lai_mutex );