if ( !meta_back_dobind( lc, op )
|| !meta_back_is_valid( lc, candidate ) ) {
- rs->sr_err = LDAP_OTHER;
+ rs->sr_err = LDAP_UNAVAILABLE;
send_ldap_result( op, rs );
return -1;
}
#endif
} dncookie;
+#define META_BIND_NRETRIES 3
+#define META_BIND_TIMEOUT 1000
+
int ldap_back_freeconn( Operation *op, struct ldapconn *lc );
struct ldapconn *ldap_back_getconn(struct slap_op *op, struct slap_rep *rs);
int ldap_back_dobind(struct ldapconn *lc, Operation *op, SlapReply *rs);
if ( lerr != LDAP_SUCCESS ) {
rs->sr_err = lerr;
( void )meta_clear_one_candidate( &lc->mc_conns[ i ], 1 );
+
} else {
rc = LDAP_SUCCESS;
}
LDAPMessage *res;
struct timeval tv = { 0, 0 };
int rc;
+ int nretries = 0;
/*
* handle response!!!
retry:;
switch ( ldap_result( lsc->msc_ld, msgid, 0, &tv, &res ) ) {
case 0:
- ldap_pvt_thread_yield();
- tv.tv_sec = 0;
- tv.tv_usec = 100000; /* 0.1 s */
- goto retry;
+ if ( ++nretries <= META_BIND_NRETRIES ) {
+ ldap_pvt_thread_yield();
+ tv.tv_sec = 0;
+ tv.tv_usec = META_BIND_TIMEOUT;
+ goto retry;
+ }
+ rs->sr_err = LDAP_BUSY;
+ break;
case -1:
ldap_get_option( lsc->msc_ld, LDAP_OPT_ERROR_NUMBER,
continue;
}
}
-
+
/*
* If the target is already bound it is skipped
*/
LDAPMessage *res;
struct timeval tv = { 0, 0 };
int err;
+ int nretries = 0;
/*
* handle response!!!
retry:;
switch ( ldap_result( lsc->msc_ld, msgid, 0, &tv, &res ) ) {
case 0:
- ldap_pvt_thread_yield();
- tv.tv_sec = 0;
- tv.tv_usec = 100000; /* 0.1 s */
- goto retry;
+ if ( ++nretries <= META_BIND_NRETRIES ) {
+ ldap_pvt_thread_yield();
+ tv.tv_sec = 0;
+ tv.tv_usec = META_BIND_TIMEOUT;
+ goto retry;
+ }
+
+ rc = LDAP_BUSY;
+ break;
case -1:
ldap_get_option( lsc->msc_ld, LDAP_OPT_ERROR_NUMBER,
}
if ( !meta_back_dobind( lc, op ) ) {
- rs->sr_err = LDAP_OTHER;
+ rs->sr_err = LDAP_UNAVAILABLE;
send_ldap_result( op, rs );
return -1;
}
return -1;
}
- if ( !meta_back_dobind( lc, op )
- || !meta_back_is_valid( lc, candidate ) ) {
+ if ( !meta_back_dobind( lc, op ) ) {
+ rs->sr_err = LDAP_UNAVAILABLE;
+
+ } else if ( !meta_back_is_valid( lc, candidate ) ) {
rs->sr_err = LDAP_OTHER;
+ }
+
+ if ( rs->sr_err != LDAP_SUCCESS ) {
send_ldap_result( op, rs );
return -1;
}
goto cleanup;
}
- if ( !meta_back_dobind( lc, op )
- || !meta_back_is_valid( lc, candidate ) )
- {
+ if ( !meta_back_dobind( lc, op ) ) {
+ rs->sr_err = LDAP_UNAVAILABLE;
+
+ } else if ( !meta_back_is_valid( lc, candidate ) ) {
rs->sr_err = LDAP_OTHER;
+ }
+
+ if ( rs->sr_err != LDAP_SUCCESS ) {
rc = -1;
goto cleanup;
}
assert( candidate != META_TARGET_NONE );
- if ( !meta_back_dobind( lc, op )
- || !meta_back_is_valid( lc, candidate ) )
- {
+ if ( !meta_back_dobind( lc, op ) ) {
+ rs->sr_err = LDAP_UNAVAILABLE;
+
+ } else if ( !meta_back_is_valid( lc, candidate ) ) {
rs->sr_err = LDAP_OTHER;
+ }
+
+ if ( rs->sr_err != LDAP_SUCCESS ) {
rc = -1;
goto cleanup;
}
}
if ( !meta_back_dobind( lc, op ) ) {
- rs->sr_err = LDAP_OTHER;
+ rs->sr_err = LDAP_UNAVAILABLE;
send_ldap_result( op, rs );
return -1;
}