From: Pierangelo Masarati Date: Sat, 8 Jan 2005 10:59:32 +0000 (+0000) Subject: fix ITS#3464 X-Git-Tag: OPENLDAP_REL_ENG_2_3_BP~450 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=8d14165274b244d6f91587502bd0a23ec7b08a87;p=openldap fix ITS#3464 --- diff --git a/servers/slapd/back-meta/add.c b/servers/slapd/back-meta/add.c index ba5e2052cb..17710ba235 100644 --- a/servers/slapd/back-meta/add.c +++ b/servers/slapd/back-meta/add.c @@ -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; } diff --git a/servers/slapd/back-meta/back-meta.h b/servers/slapd/back-meta/back-meta.h index c377ffc25a..cd82865fb9 100644 --- a/servers/slapd/back-meta/back-meta.h +++ b/servers/slapd/back-meta/back-meta.h @@ -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); diff --git a/servers/slapd/back-meta/bind.c b/servers/slapd/back-meta/bind.c index 59987d77c0..36dc7af36c 100644 --- a/servers/slapd/back-meta/bind.c +++ b/servers/slapd/back-meta/bind.c @@ -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, diff --git a/servers/slapd/back-meta/compare.c b/servers/slapd/back-meta/compare.c index e53b9a0bb1..9a808a9581 100644 --- a/servers/slapd/back-meta/compare.c +++ b/servers/slapd/back-meta/compare.c @@ -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; } diff --git a/servers/slapd/back-meta/delete.c b/servers/slapd/back-meta/delete.c index e0d5171925..13f8f527d9 100644 --- a/servers/slapd/back-meta/delete.c +++ b/servers/slapd/back-meta/delete.c @@ -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; } diff --git a/servers/slapd/back-meta/modify.c b/servers/slapd/back-meta/modify.c index 2f53b06076..de3ca1bd44 100644 --- a/servers/slapd/back-meta/modify.c +++ b/servers/slapd/back-meta/modify.c @@ -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; } diff --git a/servers/slapd/back-meta/modrdn.c b/servers/slapd/back-meta/modrdn.c index 7f8b604bb5..d4ea67f895 100644 --- a/servers/slapd/back-meta/modrdn.c +++ b/servers/slapd/back-meta/modrdn.c @@ -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; } diff --git a/servers/slapd/back-meta/search.c b/servers/slapd/back-meta/search.c index 620e2be92e..0ef44b9a38 100644 --- a/servers/slapd/back-meta/search.c +++ b/servers/slapd/back-meta/search.c @@ -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; }