about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBrooks Moses <bmoses@google.com>2015-01-30 14:01:03 -0800
committerBrooks Moses <bmoses@google.com>2015-01-30 14:01:03 -0800
commitdaee27e94cfb86c069343e91bc986529cbd51bf1 (patch)
tree75141563939da8d33c38600a61d685e4030fd12c
parent1d1e0535b6fb597f52f9123b6613add0cdaa8481 (diff)
downloadglibc-daee27e94cfb86c069343e91bc986529cbd51bf1.tar.gz
glibc-daee27e94cfb86c069343e91bc986529cbd51bf1.tar.xz
glibc-daee27e94cfb86c069343e91bc986529cbd51bf1.zip
Port "resolv.conf timestamp checks" fixes from eglibc sources.
-rw-r--r--README.google3
-rw-r--r--resolv/res_libc.c15
2 files changed, 16 insertions, 2 deletions
diff --git a/README.google b/README.google
index 05c21c995b..3589cc8616 100644
--- a/README.google
+++ b/README.google
@@ -417,3 +417,6 @@ sysdeps/x86_64/start.S
 dlfcn/dlopen.c
   Re-fix b/18243822 which got broken by cr/80600560 (AARCH64 build fix).
   (ppluzhnikov, google-local)
+
+resolv/res_libc.c
+  For b/18473393, port r9102, r11566, and r14311 from eglibc sources.
diff --git a/resolv/res_libc.c b/resolv/res_libc.c
index ee3fa2114b..29e2340fea 100644
--- a/resolv/res_libc.c
+++ b/resolv/res_libc.c
@@ -22,12 +22,13 @@
 #include <arpa/nameser.h>
 #include <resolv.h>
 #include <bits/libc-lock.h>
-
+#include <sys/stat.h>
 
 /* The following bit is copied from res_data.c (where it is #ifdef'ed
    out) since res_init() should go into libc.so but the rest of that
    file should not.  */
 
+__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
@@ -35,7 +36,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
@@ -94,7 +94,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);