diff options
author | Arthur de Jong <arthur@arthurdejong.org> | 2013-08-20 16:16:24 +0200 |
---|---|---|
committer | Arthur de Jong <arthur@arthurdejong.org> | 2013-08-21 21:42:18 +0200 |
commit | 8bdb28933154d9ee0e7e45e68c094bc507cb89db (patch) | |
tree | ff0d70881acd71e11625b6280b93d5bfd72f7d89 /nslcd/myldap.c | |
parent | d58f163b5aceb570aa7bd41b2c8edb3307a3a980 (diff) |
Implement function for resetting reconnect times
This implemens a myldap_immediate_reconnect() function that resets the
reconnect timer to retry failing connections to the LDAP server upon the
next search.
This can be used to cut the reconnect_sleeptime and reconnect_retrytime
sleeping periodss short if we have some indication that the LDAP server
is available again.
Diffstat (limited to 'nslcd/myldap.c')
-rw-r--r-- | nslcd/myldap.c | 22 |
1 files changed, 22 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) |