From: Pierangelo Masarati Date: Tue, 1 Nov 2005 16:36:17 +0000 (+0000) Subject: various cleanup X-Git-Tag: OPENLDAP_REL_ENG_2_2_MP~146 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=3cb2bc0c56d87d7c39b96809ab5660cd953d0540;p=openldap various cleanup --- diff --git a/servers/slapd/back-meta/bind.c b/servers/slapd/back-meta/bind.c index 6d890c5678..3d59cf27d4 100644 --- a/servers/slapd/back-meta/bind.c +++ b/servers/slapd/back-meta/bind.c @@ -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 ); diff --git a/servers/slapd/back-meta/candidates.c b/servers/slapd/back-meta/candidates.c index 1254a26184..1cc8d83a87 100644 --- a/servers/slapd/back-meta/candidates.c +++ b/servers/slapd/back-meta/candidates.c @@ -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 ); } diff --git a/servers/slapd/back-meta/conn.c b/servers/slapd/back-meta/conn.c index 9254407e45..8c341899d7 100644 --- a/servers/slapd/back-meta/conn.c +++ b/servers/slapd/back-meta/conn.c @@ -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 ); diff --git a/servers/slapd/back-meta/init.c b/servers/slapd/back-meta/init.c index 3f71a429f2..b78a652ccc 100644 --- a/servers/slapd/back-meta/init.c +++ b/servers/slapd/back-meta/init.c @@ -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 ) { diff --git a/servers/slapd/back-meta/unbind.c b/servers/slapd/back-meta/unbind.c index ed4bc96e30..a38bfa2b07 100644 --- a/servers/slapd/back-meta/unbind.c +++ b/servers/slapd/back-meta/unbind.c @@ -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 ); }