aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/unix/sysv
diff options
context:
space:
mode:
authorRoland McGrath <roland@hack.frob.com>2012-08-22 13:31:12 -0700
committerRoland McGrath <roland@hack.frob.com>2012-08-22 13:31:12 -0700
commit3cc3ef96d6c060e9d45b43f5482dc4e03945b30e (patch)
tree38fbe47c74c5109f408d107696950923d1b68ff6 /sysdeps/unix/sysv
parent07e515506660b1d0c1934dc0ac0e2ac5e7a4a760 (diff)
downloadglibc-3cc3ef96d6c060e9d45b43f5482dc4e03945b30e.tar
glibc-3cc3ef96d6c060e9d45b43f5482dc4e03945b30e.tar.gz
glibc-3cc3ef96d6c060e9d45b43f5482dc4e03945b30e.tar.bz2
glibc-3cc3ef96d6c060e9d45b43f5482dc4e03945b30e.zip
BZ#13696: Add --disable-nscd configure option.
Diffstat (limited to 'sysdeps/unix/sysv')
-rw-r--r--sysdeps/unix/sysv/linux/check_pf.c38
1 files changed, 25 insertions, 13 deletions
diff --git a/sysdeps/unix/sysv/linux/check_pf.c b/sysdeps/unix/sysv/linux/check_pf.c
index 950498acd4..eebb3a4839 100644
--- a/sysdeps/unix/sysv/linux/check_pf.c
+++ b/sysdeps/unix/sysv/linux/check_pf.c
@@ -78,6 +78,29 @@ __bump_nl_timestamp (void)
}
#endif
+static inline uint32_t
+get_nl_timestamp (void)
+{
+#ifdef IS_IN_nscd
+ return nl_timestamp;
+#elif defined USE_NSCD
+ return __nscd_get_nl_timestamp ();
+#else
+ return 0;
+#endif
+}
+
+static inline bool
+cache_valid_p (void)
+{
+ if (cache != NULL)
+ {
+ uint32_t timestamp = get_nl_timestamp ();
+ return timestamp != 0 && cache->timestamp == timestamp;
+ }
+ return false;
+}
+
static struct cached_data *
make_request (int fd, pid_t pid)
@@ -253,11 +276,7 @@ make_request (int fd, pid_t pid)
if (result == NULL)
goto out_fail;
-#ifdef IS_IN_nscd
- result->timestamp = nl_timestamp;
-#else
- result->timestamp = __nscd_get_nl_timestamp ();
-#endif
+ result->timestamp = get_nl_timestamp ();
result->usecnt = 2;
result->seen_ipv4 = seen_ipv4;
result->seen_ipv6 = true;
@@ -302,14 +321,7 @@ __check_pf (bool *seen_ipv4, bool *seen_ipv6,
__libc_lock_lock (lock);
-#ifdef IS_IN_nscd
-# define cache_valid() nl_timestamp != 0 && cache->timestamp == nl_timestamp
-#else
-# define cache_valid() \
- ({ uint32_t val = __nscd_get_nl_timestamp (); \
- val != 0 && cache->timestamp == val; })
-#endif
- if (cache != NULL && cache_valid ())
+ if (cache_valid_p ())
{
data = cache;
atomic_increment (&cache->usecnt);