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 );
}
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 );
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 );
}
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 );
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 );
* 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 ) {
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,
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 );
}