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 /* NOTE: lc_lcflags is redefined to msc_mscflags to reuse the macros
* defined for back-ldap */ * defined for back-ldap */
#define lc_lcflags msc_mscflags #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; struct metainfo_t *msc_info;
} metasingleconn_t; } metasingleconn_t;

View file

@ -679,9 +679,22 @@ meta_back_dobind(
/* /*
* If the target is already bound it is skipped * 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 ) ) { if ( LDAP_BACK_CONN_ISBOUND( msc ) || LDAP_BACK_CONN_ISANON( msc ) ) {
ldap_pvt_thread_mutex_unlock( &mi->mi_conninfo.lai_mutex );
++bound; ++bound;
continue; 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:; retry:;
@ -739,11 +752,14 @@ retry:;
op->o_log_prefix, i, op->o_log_prefix, i,
rootdn ? rootdn : "anonymous" ); rootdn ? rootdn : "anonymous" );
ldap_pvt_thread_mutex_lock( &mi->mi_conninfo.lai_mutex );
LDAP_BACK_CONN_BINDING_CLEAR( msc );
if ( rootdn ) { if ( rootdn ) {
LDAP_BACK_CONN_ISBOUND_SET( msc ); LDAP_BACK_CONN_ISBOUND_SET( msc );
} else { } else {
LDAP_BACK_CONN_ISANON_SET( msc ); LDAP_BACK_CONN_ISANON_SET( msc );
} }
ldap_pvt_thread_mutex_unlock( &mi->mi_conninfo.lai_mutex );
++bound; ++bound;
} }

View file

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