From 319b9ad4bccedb2a6b1a222cf446e873b2bc6de1 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Mon, 11 Jul 2011 14:50:24 -0400 Subject: Generalize framework to register monitoring of files in nscd nscd can clear caches when certain files change. The list of files was hardcoded so far and worked for nss_files and nss_dns and those modules which need no monitoring. nss_db, for instance, has its own set of files to monitor. Now the NSS modules themselves can request that certain files are monitored. --- nscd/cache.c | 46 +++++++++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 17 deletions(-) (limited to 'nscd/cache.c') diff --git a/nscd/cache.c b/nscd/cache.c index ebc6e4c0d6..58f0bcc5f1 100644 --- a/nscd/cache.c +++ b/nscd/cache.c @@ -264,28 +264,40 @@ prune_cache (struct database_dyn *table, time_t now, int fd) /* If we check for the modification of the underlying file we invalidate the entries also in this case. */ - if (table->inotify_descr < 0 && table->check_file && now != LONG_MAX) + if (table->check_file && now != LONG_MAX) { - struct stat64 st; + struct traced_file *runp = table->traced_files; - if (stat64 (table->filename, &st) < 0) + while (runp != NULL) { - char buf[128]; - /* We cannot stat() the file, disable file checking if the - file does not exist. */ - dbg_log (_("cannot stat() file `%s': %s"), - table->filename, strerror_r (errno, buf, sizeof (buf))); - if (errno == ENOENT) - table->check_file = 0; - } - else - { - if (st.st_mtime != table->file_mtime) +#ifdef HAVE_INOTIFY + if (runp->inotify_descr == -1) +#endif { - /* The file changed. Invalidate all entries. */ - now = LONG_MAX; - table->file_mtime = st.st_mtime; + struct stat64 st; + + if (stat64 (runp->fname, &st) < 0) + { + char buf[128]; + /* We cannot stat() the file, disable file checking if the + file does not exist. */ + dbg_log (_("cannot stat() file `%s': %s"), + runp->fname, strerror_r (errno, buf, sizeof (buf))); + if (errno == ENOENT) + table->check_file = 0; + } + else + { + if (st.st_mtime != table->file_mtime) + { + /* The file changed. Invalidate all entries. */ + now = LONG_MAX; + table->file_mtime = st.st_mtime; + } + } } + + runp = runp->next; } } -- cgit 1.4.1