mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-22 23:59:34 -05:00
Rework do_ldap retry loop to better handle server down errors.
Could likely treat other errors (LDAP_BUSY) as non-fatal errors.
This commit is contained in:
parent
9ab1282f5d
commit
af37269416
1 changed files with 79 additions and 75 deletions
|
|
@ -53,7 +53,7 @@ static int do_unbind LDAP_P(( Ri * ));
|
||||||
/*
|
/*
|
||||||
* Determine the type of ldap operation being performed and call the
|
* Determine the type of ldap operation being performed and call the
|
||||||
* appropriate routine.
|
* appropriate routine.
|
||||||
* - If successful, returns ERR_DO_LDAP_OK
|
* - If successful, returns DO_LDAP_OK
|
||||||
* - If a retryable error occurs, ERR_DO_LDAP_RETRYABLE is returned.
|
* - If a retryable error occurs, ERR_DO_LDAP_RETRYABLE is returned.
|
||||||
* The caller should wait a while and retry the operation.
|
* The caller should wait a while and retry the operation.
|
||||||
* - If a fatal error occurs, ERR_DO_LDAP_FATAL is returned. The caller
|
* - If a fatal error occurs, ERR_DO_LDAP_FATAL is returned. The caller
|
||||||
|
|
@ -67,17 +67,15 @@ do_ldap(
|
||||||
char **errmsg
|
char **errmsg
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
|
||||||
int lderr = LDAP_SUCCESS;
|
|
||||||
int retry = 2;
|
int retry = 2;
|
||||||
|
|
||||||
*errmsg = NULL;
|
*errmsg = NULL;
|
||||||
|
|
||||||
while ( retry > 0 ) {
|
do {
|
||||||
|
int lderr;
|
||||||
if ( ri->ri_ldp == NULL ) {
|
if ( ri->ri_ldp == NULL ) {
|
||||||
rc = do_bind( ri, &lderr );
|
lderr = do_bind( ri, &lderr );
|
||||||
|
|
||||||
if ( rc != BIND_OK ) {
|
if ( lderr != BIND_OK ) {
|
||||||
return DO_LDAP_ERR_RETRYABLE;
|
return DO_LDAP_ERR_RETRYABLE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -92,6 +90,7 @@ do_ldap(
|
||||||
re->re_dn, 0 );
|
re->re_dn, 0 );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_MODIFYCT:
|
case T_MODIFYCT:
|
||||||
lderr = op_ldap_modify( ri, re, errmsg );
|
lderr = op_ldap_modify( ri, re, errmsg );
|
||||||
if ( lderr != LDAP_SUCCESS ) {
|
if ( lderr != LDAP_SUCCESS ) {
|
||||||
|
|
@ -101,6 +100,7 @@ do_ldap(
|
||||||
re->re_dn, 0 );
|
re->re_dn, 0 );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_DELETECT:
|
case T_DELETECT:
|
||||||
lderr = op_ldap_delete( ri, re, errmsg );
|
lderr = op_ldap_delete( ri, re, errmsg );
|
||||||
if ( lderr != LDAP_SUCCESS ) {
|
if ( lderr != LDAP_SUCCESS ) {
|
||||||
|
|
@ -110,6 +110,7 @@ do_ldap(
|
||||||
re->re_dn, 0 );
|
re->re_dn, 0 );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_MODRDNCT:
|
case T_MODRDNCT:
|
||||||
lderr = op_ldap_modrdn( ri, re, errmsg );
|
lderr = op_ldap_modrdn( ri, re, errmsg );
|
||||||
if ( lderr != LDAP_SUCCESS ) {
|
if ( lderr != LDAP_SUCCESS ) {
|
||||||
|
|
@ -119,6 +120,7 @@ do_ldap(
|
||||||
re->re_dn, 0 );
|
re->re_dn, 0 );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Debug( LDAP_DEBUG_ANY,
|
Debug( LDAP_DEBUG_ANY,
|
||||||
"Error: do_ldap: bad op \"%d\", dn = \"%s\"\n",
|
"Error: do_ldap: bad op \"%d\", dn = \"%s\"\n",
|
||||||
|
|
@ -131,19 +133,21 @@ do_ldap(
|
||||||
* we may have been idle long enough that the remote slapd timed
|
* we may have been idle long enough that the remote slapd timed
|
||||||
* us out. Rebind and try again.
|
* us out. Rebind and try again.
|
||||||
*/
|
*/
|
||||||
if ( lderr == LDAP_SUCCESS ) {
|
switch( lderr ) {
|
||||||
|
case LDAP_SUCCESS:
|
||||||
return DO_LDAP_OK;
|
return DO_LDAP_OK;
|
||||||
} else if ( lderr == LDAP_SERVER_DOWN ) {
|
|
||||||
/* The LDAP server may have timed us out - rebind and try again */
|
default:
|
||||||
|
return DO_LDAP_ERR_FATAL;
|
||||||
|
|
||||||
|
case LDAP_SERVER_DOWN: /* server went down */
|
||||||
(void) do_unbind( ri );
|
(void) do_unbind( ri );
|
||||||
retry--;
|
retry--;
|
||||||
} else {
|
|
||||||
return DO_LDAP_ERR_FATAL;
|
|
||||||
}
|
}
|
||||||
}
|
} while ( retry > 0 );
|
||||||
return DO_LDAP_ERR_FATAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
return DO_LDAP_ERR_RETRYABLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue