]> git.sur5r.net Git - openldap/commitdiff
various cleanup
authorPierangelo Masarati <ando@openldap.org>
Tue, 1 Nov 2005 16:36:17 +0000 (16:36 +0000)
committerPierangelo Masarati <ando@openldap.org>
Tue, 1 Nov 2005 16:36:17 +0000 (16:36 +0000)
servers/slapd/back-meta/bind.c
servers/slapd/back-meta/candidates.c
servers/slapd/back-meta/conn.c
servers/slapd/back-meta/init.c
servers/slapd/back-meta/unbind.c

index 6d890c56781c77b89656d2cead94c6fac637b2c9..3d59cf27d4965760eddca6d21e392c2f64fc3d4a 100644 (file)
@@ -380,8 +380,7 @@ retry:;
                        if ( rs->sr_err == LDAP_UNAVAILABLE && nretries != META_RETRY_NEVER ) {
                                ldap_pvt_thread_mutex_lock( &mi->mi_conn_mutex );
                                if ( mc->mc_refcnt == 1 ) {
-                                       ldap_unbind_ext_s( msc->msc_ld, NULL, NULL );
-                                       msc->msc_ld = NULL;
+                                       meta_clear_one_candidate( msc );
                                        LDAP_BACK_CONN_ISBOUND_CLEAR( msc );
 
                                        ( void )rewrite_session_delete( mt->mt_rwmap.rwm_rw, op->o_conn );
@@ -558,8 +557,7 @@ retry:;
                                }
 
                                if ( mc->mc_refcnt == 1 ) {
-                                       ldap_unbind_ext_s( msc->msc_ld, NULL, NULL );
-                                       msc->msc_ld = NULL;
+                                       meta_clear_one_candidate( msc );
                                        LDAP_BACK_CONN_ISBOUND_CLEAR( msc );
 
                                        ( void )rewrite_session_delete( mt->mt_rwmap.rwm_rw, op->o_conn );
index 1254a26184ea52ec93a5dea7de2c2524309dc2d7..1cc8d83a87a38e46f49892ada7463ca6f6511ba1 100644 (file)
@@ -178,18 +178,18 @@ meta_clear_one_candidate(
        metasingleconn_t        *msc )
 {
        if ( msc->msc_ld ) {
-               ldap_unbind_ext_s( msc->msc_ld, NULL, NULL );
+               ldap_unbind_ext( msc->msc_ld, NULL, NULL );
                msc->msc_ld = NULL;
        }
 
        if ( !BER_BVISNULL( &msc->msc_bound_ndn ) ) {
-               ber_memfree( msc->msc_bound_ndn.bv_val );
+               ber_memfree_x( msc->msc_bound_ndn.bv_val, NULL );
                BER_BVZERO( &msc->msc_bound_ndn );
        }
 
        if ( !BER_BVISNULL( &msc->msc_cred ) ) {
                memset( msc->msc_cred.bv_val, 0, msc->msc_cred.bv_len );
-               ber_memfree( msc->msc_cred.bv_val );
+               ber_memfree_x( msc->msc_cred.bv_val, NULL );
                BER_BVZERO( &msc->msc_cred );
        }
 
index 9254407e45f515370323ff6a1a3dc9683b57bf13..8c341899d7c416ef53aaa3d52e1784e6b5c8e817 100644 (file)
@@ -447,8 +447,7 @@ retry_lock:;
                        goto retry_lock;
                }
 
-               ldap_unbind_ext_s( msc->msc_ld, NULL, NULL );
-               msc->msc_ld = NULL;
+               meta_clear_one_candidate( msc );
                LDAP_BACK_CONN_ISBOUND_CLEAR( msc );
 
                ( void )rewrite_session_delete( mt->mt_rwmap.rwm_rw, op->o_conn );
index 3f71a429f25882e9ca123a5474241d74e4404e5e..b78a652ccc7752316ec427a4562eed8113e581ea 100644 (file)
@@ -146,21 +146,7 @@ meta_back_conn_free(
        ntargets = mc->mc_conns[ 0 ].msc_info->mi_ntargets;
 
        for ( i = 0; i < ntargets; i++ ) {
-               metasingleconn_t        *msc = &mc->mc_conns[ i ];
-
-               if ( msc->msc_ld != NULL ) {
-                       ldap_unbind_ext_s( msc->msc_ld, NULL, NULL );
-               }
-
-               if ( !BER_BVISNULL( &msc->msc_bound_ndn ) ) {
-                       ber_memfree( msc->msc_bound_ndn.bv_val );
-               }
-
-               if ( !BER_BVISNULL( &msc->msc_cred ) ) {
-                       /* destroy sensitive data */
-                       memset( msc->msc_cred.bv_val, 0, msc->msc_cred.bv_len );
-                       ber_memfree( msc->msc_cred.bv_val );
-               }
+               (void)meta_clear_one_candidate( &mc->mc_conns[ i ] );
        }
 
        ldap_pvt_thread_mutex_destroy( &mc->mc_mutex );
@@ -235,11 +221,13 @@ meta_back_db_destroy(
                 * Destroy the per-target stuff (assuming there's at
                 * least one ...)
                 */
-               for ( i = 0; i < mi->mi_ntargets; i++ ) {
-                       target_free( &mi->mi_targets[ i ] );
-               }
+               if ( mi->mi_targets != NULL ) {
+                       for ( i = 0; i < mi->mi_ntargets; i++ ) {
+                               target_free( &mi->mi_targets[ i ] );
+                       }
 
-               free( mi->mi_targets );
+                       free( mi->mi_targets );
+               }
 
                ldap_pvt_thread_mutex_lock( &mi->mi_cache.mutex );
                if ( mi->mi_cache.tree ) {
index ed4bc96e30e82339f83857ef7ce7e01f22632b0c..a38bfa2b0729314d8209d6642b3894d2a8db9616 100644 (file)
@@ -48,6 +48,7 @@ meta_back_conn_destroy(
                conn->c_connid, 0, 0 );
        
        mc_curr.mc_conn = conn;
+       mc_curr.mc_local_ndn = conn->c_ndn;
        
        ldap_pvt_thread_mutex_lock( &mi->mi_conn_mutex );
        mc = avl_delete( &mi->mi_conntree, ( caddr_t )&mc_curr,
@@ -61,12 +62,6 @@ meta_back_conn_destroy(
                
                assert( mc->mc_refcnt == 0 );
 
-               for ( i = 0; i < mi->mi_ntargets; ++i ) {
-                       if ( mc->mc_conns[ i ].msc_ld != NULL ) {
-                               meta_clear_one_candidate( &mc->mc_conns[ i ] );
-                       }
-               }
-
                meta_back_conn_free( mc );
        }