From 723a31d3e2627211b39fbcc08f75b3c23c4096c5 Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Thu, 31 Dec 2015 15:10:33 -0800 Subject: [PATCH 20/25] eglibc: cherry-picked from http://www.eglibc.org/archives/patches/msg00772.html Not yet merged into glibc Upstream-Status: Pending Signed-off-by: Khem Raj --- resolv/res_libc.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/resolv/res_libc.c b/resolv/res_libc.c index a4b376f..3256e12 100644 --- a/resolv/res_libc.c +++ b/resolv/res_libc.c @@ -21,11 +21,13 @@ #include #include #include +#include #include #include #include #include +__libc_lock_define_initialized (static, lock); extern unsigned long long int __res_initstamp attribute_hidden; /* We have atomic increment operations on 64-bit platforms. */ #if __WORDSIZE == 64 @@ -33,7 +35,6 @@ extern unsigned long long int __res_initstamp attribute_hidden; # define atomicincunlock(lock) (void) 0 # define atomicinc(var) catomic_increment (&(var)) #else -__libc_lock_define_initialized (static, lock); # define atomicinclock(lock) __libc_lock_lock (lock) # define atomicincunlock(lock) __libc_lock_unlock (lock) # define atomicinc(var) ++var @@ -92,7 +93,18 @@ res_init(void) { int __res_maybe_init (res_state resp, int preinit) { + static time_t last_mtime; + struct stat statbuf; + int ret; + if (resp->options & RES_INIT) { + ret = stat (_PATH_RESCONF, &statbuf); + __libc_lock_lock (lock); + if ((ret == 0) && (last_mtime != statbuf.st_mtime)) { + last_mtime = statbuf.st_mtime; + atomicinc (__res_initstamp); + } + __libc_lock_unlock (lock); if (__res_initstamp != resp->_u._ext.initstamp) { if (resp->nscount > 0) __res_iclose (resp, true); -- 2.8.2