diff options
| -rw-r--r-- | nslcd/myldap.c | 22 | ||||
| -rw-r--r-- | nslcd/myldap.h | 4 |
2 files changed, 26 insertions, 0 deletions
diff --git a/nslcd/myldap.c b/nslcd/myldap.c index b2258d4..757eb20 100644 --- a/nslcd/myldap.c +++ b/nslcd/myldap.c @@ -1257,6 +1257,28 @@ static int do_retry_search(MYLDAP_SEARCH *search) } } +/* force quick retries of all failing LDAP servers */ +void myldap_immediate_reconnect(void) +{ + int i; + time_t t; + t = time(NULL) - nslcd_cfg->reconnect_retrytime; + pthread_mutex_lock(&uris_mutex); + for (i = 0; i < (NSS_LDAP_CONFIG_MAX_URIS + 1); i++) + { + /* only adjust failing connections that are in a hard fail state */ + if ((nslcd_cfg->uris[i].lastfail > t) && + (nslcd_cfg->uris[i].lastfail > (nslcd_cfg->uris[i].firstfail + nslcd_cfg->reconnect_retrytime))) + { + /* move lastfail back to ensure quick retry */ + log_log(LOG_DEBUG, "moving lastfail of %s %d second(s) back to force retry", + nslcd_cfg->uris[i].uri, (int)(nslcd_cfg->uris[i].lastfail - t)); + nslcd_cfg->uris[i].lastfail = t; + } + } + pthread_mutex_unlock(&uris_mutex); +} + MYLDAP_SEARCH *myldap_search(MYLDAP_SESSION *session, const char *base, int scope, const char *filter, const char **attrs, int *rcp) diff --git a/nslcd/myldap.h b/nslcd/myldap.h index 9367b43..8c4551a 100644 --- a/nslcd/myldap.h +++ b/nslcd/myldap.h @@ -90,6 +90,10 @@ void myldap_session_check(MYLDAP_SESSION *session); After a call to this function the referenced handle is invalid. */ void myldap_session_close(MYLDAP_SESSION *session); +/* Mark all failing LDAP servers as needing quick retries. This ensures that the + reconnect_sleeptime and reconnect_retrytime sleeping period is cut short. */ +void myldap_immediate_reconnect(void); + /* Do an LDAP search and return a reference to the results (returns NULL on error). This function uses paging, and does reconnects to the configured URLs transparently. The function returns an LDAP status code in the |
