make sure only on bind at a time occurs; release resources only when appropriate

This commit is contained in:
Pierangelo Masarati 2006-04-04 17:41:50 +00:00
parent 2e9f2995ec
commit 543396c804
3 changed files with 24 additions and 12 deletions

View File

@ -167,12 +167,6 @@ typedef struct metasingleconn_t {
/* NOTE: lc_lcflags is redefined to msc_mscflags to reuse the macros
* defined for back-ldap */
#define lc_lcflags msc_mscflags
#if 0
int msc_bound;
#define META_UNBOUND 0
#define META_BOUND 1
#define META_ANONYMOUS 2
#endif
struct metainfo_t *msc_info;
} metasingleconn_t;

View File

@ -679,10 +679,23 @@ meta_back_dobind(
/*
* If the target is already bound it is skipped
*/
retry_binding:;
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 );
++bound;
continue;
}
} else if ( LDAP_BACK_CONN_BINDING( msc ) ) {
ldap_pvt_thread_mutex_unlock( &mi->mi_conninfo.lai_mutex );
ldap_pvt_thread_yield();
goto retry_binding;
} else {
LDAP_BACK_CONN_BINDING_SET( msc );
ldap_pvt_thread_mutex_unlock( &mi->mi_conninfo.lai_mutex );
}
retry:;
rc = meta_back_single_dobind( op, rs, &mc, i,
@ -739,11 +752,14 @@ retry:;
op->o_log_prefix, i,
rootdn ? rootdn : "anonymous" );
ldap_pvt_thread_mutex_lock( &mi->mi_conninfo.lai_mutex );
LDAP_BACK_CONN_BINDING_CLEAR( msc );
if ( rootdn ) {
LDAP_BACK_CONN_ISBOUND_SET( msc );
} else {
LDAP_BACK_CONN_ISANON_SET( msc );
}
ldap_pvt_thread_mutex_unlock( &mi->mi_conninfo.lai_mutex );
++bound;
}

View File

@ -213,7 +213,7 @@ metaconn_alloc(
mc->mc_conns[ i ].msc_ld = NULL;
BER_BVZERO( &mc->mc_conns[ i ].msc_bound_ndn );
BER_BVZERO( &mc->mc_conns[ i ].msc_cred );
LDAP_BACK_CONN_ISBOUND_CLEAR( &mc->mc_conns[ i ] );
mc->mc_conns[ i ].msc_mscflags = 0;
mc->mc_conns[ i ].msc_info = mi;
}
@ -270,6 +270,8 @@ meta_back_init_one_conn(
if ( msc->msc_ld != NULL ) {
return rs->sr_err = LDAP_SUCCESS;
}
msc->msc_mscflags = 0;
/*
* Attempts to initialize the connection to the target ds
@ -453,8 +455,6 @@ retry:;
assert( !BER_BVISNULL( &msc->msc_bound_ndn ) );
LDAP_BACK_CONN_ISBOUND_CLEAR( msc );
error_return:;
if ( rs->sr_err == LDAP_SUCCESS ) {
/*
@ -523,8 +523,10 @@ meta_back_retry(
}
if ( rc != LDAP_SUCCESS ) {
meta_back_release_conn_lock( op, mc, 1, 0 );
*mcp = NULL;
if ( *mcp != NULL ) {
meta_back_release_conn_lock( op, mc, 1, 0 );
*mcp = NULL;
}
if ( sendok ) {
rs->sr_err = LDAP_UNAVAILABLE;