summaryrefslogtreecommitdiff
path: root/nslcd
diff options
context:
space:
mode:
authorArthur de Jong <arthur@arthurdejong.org>2013-10-25 23:25:00 +0200
committerArthur de Jong <arthur@arthurdejong.org>2013-10-25 23:36:03 +0200
commit1d8db24de6fce25997b1e672c497daf9b60ac725 (patch)
tree177170530694d8b2eb3cb09340b5fea731dabd1c /nslcd
parentee8737f1a1d048f5b06ce479337e72382e36bf8f (diff)
Also run invalidators on initial connect
This also invalidates the caches configured with reconnect_invalidate on the first successful search. This should handle the case more gracefully where caches were filled with negative hits before nslcd was running.
Diffstat (limited to 'nslcd')
-rw-r--r--nslcd/myldap.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/nslcd/myldap.c b/nslcd/myldap.c
index 959669b..235c3c6 100644
--- a/nslcd/myldap.c
+++ b/nslcd/myldap.c
@@ -150,6 +150,9 @@ struct myldap_entry {
char **rangedattributevalues[MAX_RANGED_ATTRIBUTES_PER_ENTRY];
};
+/* Flag to record first search operation */
+int first_search = 1;
+
static void myldap_err(int pri, LDAP *ld, int rc, const char *format, ...)
{
char message[200];
@@ -1159,6 +1162,7 @@ static int do_retry_search(MYLDAP_SEARCH *search)
int rc = LDAP_UNAVAILABLE;
struct myldap_uri *current_uri;
int dotry[NSS_LDAP_CONFIG_MAX_URIS];
+ int do_invalidate = 0;
/* clear time stamps */
for (start_uri = 0; start_uri < NSS_LDAP_CONFIG_MAX_URIS; start_uri++)
dotry[start_uri] = 1;
@@ -1197,8 +1201,12 @@ static int do_retry_search(MYLDAP_SEARCH *search)
if ((current_uri->lastfail > 0) || (search->session->current_uri != start_uri))
{
log_log(LOG_INFO, "connected to LDAP server %s", current_uri->uri);
- /* signal external invalidation of configured caches */
- invalidator_do(LM_NONE);
+ do_invalidate = 1;
+ }
+ if (first_search)
+ {
+ do_invalidate = 1;
+ first_search = 0;
}
/* update ok time */
current_uri->firstfail = 0;
@@ -1206,6 +1214,9 @@ static int do_retry_search(MYLDAP_SEARCH *search)
pthread_mutex_unlock(&uris_mutex);
/* flag the search as valid */
search->valid = 1;
+ /* signal external invalidation of configured caches */
+ if (do_invalidate)
+ invalidator_do(LM_NONE);
return LDAP_SUCCESS;
}
/* close the current connection */