/* 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;
/*
* 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,
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;
}
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;
}
if ( msc->msc_ld != NULL ) {
return rs->sr_err = LDAP_SUCCESS;
}
+
+ msc->msc_mscflags = 0;
/*
* Attempts to initialize the connection to the target ds
assert( !BER_BVISNULL( &msc->msc_bound_ndn ) );
- LDAP_BACK_CONN_ISBOUND_CLEAR( msc );
-
error_return:;
if ( rs->sr_err == LDAP_SUCCESS ) {
/*
}
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;