From 3cc3ef96d6c060e9d45b43f5482dc4e03945b30e Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Wed, 22 Aug 2012 13:31:12 -0700 Subject: BZ#13696: Add --disable-nscd configure option. --- sysdeps/unix/sysv/linux/check_pf.c | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) (limited to 'sysdeps/unix/sysv/linux/check_pf.c') 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); -- cgit v1.2.3