summaryrefslogtreecommitdiff
path: root/nscd/cache.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@gmail.com>2011-07-11 14:50:24 -0400
committerUlrich Drepper <drepper@gmail.com>2011-07-11 14:50:24 -0400
commit319b9ad4bccedb2a6b1a222cf446e873b2bc6de1 (patch)
tree7951727c0dbd4394af52715e226745986e8beeb4 /nscd/cache.c
parent23bee3e8677c9357662ce789ed77fe25f3991c66 (diff)
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.
Diffstat (limited to 'nscd/cache.c')
-rw-r--r--nscd/cache.c46
1 files changed, 29 insertions, 17 deletions
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;
}
}