mirror of
https://sourceware.org/git/glibc.git
synced 2025-08-08 17:42:12 +03:00
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.
This commit is contained in:
46
nscd/cache.c
46
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user