diff options
author | Arthur de Jong <arthur@arthurdejong.org> | 2013-03-09 16:51:21 +0100 |
---|---|---|
committer | Arthur de Jong <arthur@arthurdejong.org> | 2013-03-09 19:26:39 +0100 |
commit | bf647108f90a493e72971fc302ec5b231fcc36f6 (patch) | |
tree | 707672d631fd6d9326db303da784a90ea67740cc | |
parent | d413a643faa8103878d1e977e734029158ef1a7c (diff) |
start the nscd invalidator and invalidate the nscd cache after reconnecting to the LDAP server after failure
-rw-r--r-- | nslcd/myldap.c | 4 | ||||
-rw-r--r-- | nslcd/nscd.c | 8 | ||||
-rw-r--r-- | nslcd/nslcd.c | 6 |
3 files changed, 18 insertions, 0 deletions
diff --git a/nslcd/myldap.c b/nslcd/myldap.c index c564f4b..e188fb0 100644 --- a/nslcd/myldap.c +++ b/nslcd/myldap.c @@ -1195,7 +1195,11 @@ static int do_retry_search(MYLDAP_SEARCH *search) pthread_mutex_lock(&uris_mutex); /* check if we are coming back from an error */ if ((current_uri->lastfail > 0) || (search->session->current_uri != start_uri)) + { log_log(LOG_INFO, "connected to LDAP server %s", current_uri->uri); + /* signal nscd cache invalidation */ + nscd_invalidate(LM_NONE); + } /* update ok time */ current_uri->firstfail = 0; current_uri->lastfail = 0; diff --git a/nslcd/nscd.c b/nslcd/nscd.c index c707f77..70365b4 100644 --- a/nslcd/nscd.c +++ b/nslcd/nscd.c @@ -229,6 +229,14 @@ void nscd_invalidate(enum ldap_map_selector map) int rc; if (signalfd < 0) return; + /* LM_NONE is used to signal all maps condigured in nscd_invalidate */ + if (map == LM_NONE) + { + for (map = 0; map < LM_NONE ; map++) + if (nslcd_cfg->nscd_invalidate[map]) + nscd_invalidate(map); + return; + } /* write a single byte which should be atomic and not fill the PIPE buffer too soon on most platforms (nslcd should already ignore SIGPIPE) */ diff --git a/nslcd/nslcd.c b/nslcd/nslcd.c index fc2237c..5f70963 100644 --- a/nslcd/nslcd.c +++ b/nslcd/nslcd.c @@ -705,6 +705,12 @@ int main(int argc, char *argv[]) if (!nslcd_debugging) log_startlogging(); log_log(LOG_INFO, "version %s starting", VERSION); + /* start subprocess to do nscd invalidating if nscd_invalidate is set */ + for (i = 0; i < LM_NONE; i++) + if (nslcd_cfg->nscd_invalidate[i]) + break; + if (i < LM_NONE) + nscd_start_invalidator(); /* write pidfile */ create_pidfile(NSLCD_PIDFILE); /* install handler to close stuff off on exit and log notice */ |