metaconn_t *mc );
extern int
-meta_back_retry(
+meta_back_retry_lock(
Operation *op,
SlapReply *rs,
metaconn_t *mc,
int candidate,
- ldap_back_send_t sendok );
+ ldap_back_send_t sendok,
+ int dolock );
+#define meta_back_retry(op, rs, mc, candidate, sendok) \
+ meta_back_retry_lock((op), (rs), (mc), (candidate), (sendok), 1)
extern void
meta_back_conn_free(
int ispriv,
ldap_back_send_t sendok );
+extern int
+meta_back_single_bind(
+ Operation *op,
+ SlapReply *rs,
+ metaconn_t *mc,
+ int candidate,
+ int massage );
+
extern int
meta_back_dobind(
Operation *op,
metaconn_t *mc,
ldap_back_send_t sendok );
-int
+extern int
meta_back_single_dobind(
Operation *op,
SlapReply *rs,
*/
LDAP_REBIND_PROC *meta_back_rebind_f = meta_back_default_rebind;
-static int
-meta_back_single_bind(
- Operation *op,
- SlapReply *rs,
- metaconn_t *mc,
- int candidate,
- int massage );
-
int
meta_back_bind( Operation *op, SlapReply *rs )
{
*
* attempts to perform a bind with creds
*/
-static int
+int
meta_back_single_bind(
Operation *op,
SlapReply *rs,
for ( i = 0; i < mi->mi_ntargets; i++ ) {
metatarget_t *mt = &mi->mi_targets[ i ];
metasingleconn_t *msc = &mc->mc_conns[ i ];
- int rc;
+ int rc, do_retry = 1;
char *rootdn = NULL;
/*
continue;
}
+retry:;
if ( isroot && !BER_BVISNULL( &mi->mi_targets[ i ].mt_pseudorootdn ) )
{
Operation op2 = *op;
if ( rc != LDAP_SUCCESS ) {
char buf[ SLAP_TEXT_BUFLEN ];
+ if ( rc == LDAP_UNAVAILABLE && do_retry ) {
+ do_retry = 0;
+ if ( meta_back_retry_lock( op, rs, mc, i, LDAP_BACK_DONTSEND, 0 ) ) {
+ goto retry;
+ }
+ }
+
snprintf( buf, sizeof( buf ),
"meta_back_dobind[%d]: (%s) err=%d.",
i, rootdn ? rootdn : "anonymous", rc );
}
/*
- * meta_back_retry
+ * meta_back_retry_lock
*
* Retries one connection
*/
int
-meta_back_retry(
+meta_back_retry_lock(
Operation *op,
SlapReply *rs,
metaconn_t *mc,
int candidate,
- ldap_back_send_t sendok )
+ ldap_back_send_t sendok,
+ int dolock )
{
metainfo_t *mi = ( metainfo_t * )op->o_bd->be_private;
metatarget_t *mt = &mi->mi_targets[ candidate ];
if ( mc->mc_refcnt == 1 ) {
char buf[ SLAP_TEXT_BUFLEN ];
- while ( ldap_pvt_thread_mutex_trylock( &mc->mc_mutex ) ) {
+ while ( dolock && ldap_pvt_thread_mutex_trylock( &mc->mc_mutex ) ) {
ldap_pvt_thread_mutex_unlock( &mi->mi_conninfo.lai_mutex );
ldap_pvt_thread_yield();
goto retry_lock;
LDAP_BACK_CONN_ISPRIV( mc ), sendok );
if ( rc == LDAP_SUCCESS ) {
- rc = meta_back_single_dobind( op, rs, mc, candidate,
+ if ( be_isroot( op ) && !BER_BVISNULL( &mi->mi_targets[ candidate ].mt_pseudorootdn ) )
+ {
+ Operation op2 = *op;
+
+ op2.o_tag = LDAP_REQ_BIND;
+ op2.o_req_dn = mi->mi_targets[ candidate ].mt_pseudorootdn;
+ op2.o_req_ndn = mi->mi_targets[ candidate ].mt_pseudorootdn;
+ op2.orb_cred = mi->mi_targets[ candidate ].mt_pseudorootpw;
+ op2.orb_method = LDAP_AUTH_SIMPLE;
+
+ rc = meta_back_single_bind( &op2, rs, mc, candidate, 0 );
+
+ } else {
+ rc = meta_back_single_dobind( op, rs, mc, candidate,
sendok, mt->mt_nretries, 0 );
+ }
}
- ldap_pvt_thread_mutex_unlock( &mc->mc_mutex );
+ if ( dolock ) {
+ ldap_pvt_thread_mutex_unlock( &mc->mc_mutex );
+ }
}
if ( rc != LDAP_SUCCESS ) {