blob: 4362efae777cbc9521e7be826e258f9b8a26a7a9 [file] [log] [blame]
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001From 588d936b9aa65e7cc8b1eb2cad1d209087db43a9 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Thu, 31 Dec 2015 15:10:33 -0800
4Subject: [PATCH 20/24] eglibc: cherry-picked from
5
6http://www.eglibc.org/archives/patches/msg00772.html
7
8Not yet merged into glibc
9
10Upstream-Status: Pending
11
12Signed-off-by: Khem Raj <raj.khem@gmail.com>
13---
14 resolv/res_libc.c | 14 +++++++++++++-
15 1 file changed, 13 insertions(+), 1 deletion(-)
16
17diff --git a/resolv/res_libc.c b/resolv/res_libc.c
18index a8394e0..981ac7c 100644
19--- a/resolv/res_libc.c
20+++ b/resolv/res_libc.c
21@@ -18,6 +18,7 @@
22 #include <atomic.h>
23 #include <limits.h>
24 #include <sys/types.h>
25+#include <sys/stat.h>
26 #include <netinet/in.h>
27 #include <arpa/nameser.h>
28 #include <resolv.h>
29@@ -28,6 +29,7 @@
30 out) since res_init() should go into libc.so but the rest of that
31 file should not. */
32
33+__libc_lock_define_initialized (static, lock);
34 extern unsigned long long int __res_initstamp attribute_hidden;
35 /* We have atomic increment operations on 64-bit platforms. */
36 #if __WORDSIZE == 64
37@@ -35,7 +37,6 @@ extern unsigned long long int __res_initstamp attribute_hidden;
38 # define atomicincunlock(lock) (void) 0
39 # define atomicinc(var) catomic_increment (&(var))
40 #else
41-__libc_lock_define_initialized (static, lock);
42 # define atomicinclock(lock) __libc_lock_lock (lock)
43 # define atomicincunlock(lock) __libc_lock_unlock (lock)
44 # define atomicinc(var) ++var
45@@ -94,7 +95,18 @@ res_init(void) {
46 int
47 __res_maybe_init (res_state resp, int preinit)
48 {
49+ static time_t last_mtime;
50+ struct stat statbuf;
51+ int ret;
52+
53 if (resp->options & RES_INIT) {
54+ ret = stat (_PATH_RESCONF, &statbuf);
55+ __libc_lock_lock (lock);
56+ if ((ret == 0) && (last_mtime != statbuf.st_mtime)) {
57+ last_mtime = statbuf.st_mtime;
58+ atomicinc (__res_initstamp);
59+ }
60+ __libc_lock_unlock (lock);
61 if (__res_initstamp != resp->_u._ext.initstamp) {
62 if (resp->nscount > 0)
63 __res_iclose (resp, true);
64--
652.6.4
66