aboutsummaryrefslogtreecommitdiff
path: root/nscd/nscd.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/nscd.c
parent23bee3e8677c9357662ce789ed77fe25f3991c66 (diff)
downloadglibc-319b9ad4bccedb2a6b1a222cf446e873b2bc6de1.zip
glibc-319b9ad4bccedb2a6b1a222cf446e873b2bc6de1.tar.gz
glibc-319b9ad4bccedb2a6b1a222cf446e873b2bc6de1.tar.bz2
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/nscd.c')
-rw-r--r--nscd/nscd.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/nscd/nscd.c b/nscd/nscd.c
index c3d9fe6..4894cb2 100644
--- a/nscd/nscd.c
+++ b/nscd/nscd.c
@@ -46,6 +46,9 @@
#include "selinux.h"
#include "../nss/nsswitch.h"
#include <device-nrs.h>
+#ifdef HAVE_INOTIFY
+# include <sys/inotify.h>
+#endif
/* Get libc version number. */
#include <version.h>
@@ -272,8 +275,21 @@ main (int argc, char **argv)
/* Cleanup files created by a previous 'bind'. */
unlink (_PATH_NSCDSOCKET);
+#ifdef HAVE_INOTIFY
+ /* Use inotify to recognize changed files. */
+ inotify_fd = inotify_init1 (IN_NONBLOCK);
+# ifndef __ASSUME_IN_NONBLOCK
+ if (inotify_fd == -1 && errno == ENOSYS)
+ {
+ inotify_fd = inotify_init ();
+ if (inotify_fd != -1)
+ fcntl (inotify_fd, F_SETFL, O_RDONLY | O_NONBLOCK);
+ }
+# endif
+#endif
+
/* Make sure we do not get recursive calls. */
- __nss_disable_nscd ();
+ __nss_disable_nscd (register_traced_file);
/* Init databases. */
nscd_init ();