fix ITS#3464

This commit is contained in:
Pierangelo Masarati 2005-01-08 10:59:32 +00:00
parent 83fc428a44
commit 8d14165274
8 changed files with 48 additions and 20 deletions

View File

@ -57,7 +57,7 @@ meta_back_add( Operation *op, SlapReply *rs )
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;
}

View File

@ -82,6 +82,9 @@ typedef struct dncookie {
#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);

View File

@ -118,6 +118,7 @@ meta_back_bind( 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;
}
@ -210,6 +211,7 @@ meta_back_do_single_bind(
LDAPMessage *res;
struct timeval tv = { 0, 0 };
int rc;
int nretries = 0;
/*
* handle response!!!
@ -217,10 +219,14 @@ meta_back_do_single_bind(
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,
@ -312,7 +318,7 @@ meta_back_dobind( struct metaconn *lc, Operation *op )
continue;
}
}
/*
* If the target is already bound it is skipped
*/
@ -346,6 +352,7 @@ meta_back_dobind( struct metaconn *lc, Operation *op )
LDAPMessage *res;
struct timeval tv = { 0, 0 };
int err;
int nretries = 0;
/*
* handle response!!!
@ -353,10 +360,15 @@ meta_back_dobind( struct metaconn *lc, Operation *op )
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,

View File

@ -58,7 +58,7 @@ meta_back_compare( Operation *op, SlapReply *rs )
}
if ( !meta_back_dobind( lc, op ) ) {
rs->sr_err = LDAP_OTHER;
rs->sr_err = LDAP_UNAVAILABLE;
send_ldap_result( op, rs );
return -1;
}

View File

@ -47,9 +47,14 @@ meta_back_delete( Operation *op, SlapReply *rs )
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;
}

View File

@ -52,10 +52,14 @@ meta_back_modify( Operation *op, SlapReply *rs )
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;
}

View File

@ -51,10 +51,14 @@ meta_back_modrdn( Operation *op, SlapReply *rs )
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;
}

View File

@ -78,7 +78,7 @@ meta_back_search( Operation *op, SlapReply *rs )
}
if ( !meta_back_dobind( lc, op ) ) {
rs->sr_err = LDAP_OTHER;
rs->sr_err = LDAP_UNAVAILABLE;
send_ldap_result( op, rs );
return -1;
}