aboutsummaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/glibc/glibc/0021-eglibc-cherry-picked-from-http-www.eglibc.org-archiv.patch
blob: 38bb8a15e3b78a8a345f1c4948c117ddbdbb47c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
From fe2ae4f877928dd6bff5bac3f15bce4b50d2bd12 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Wed, 18 Mar 2015 00:51:16 +0000
Subject: [PATCH 21/27] eglibc: cherry-picked from
 http://www.eglibc.org/archives/patches/msg00772.html

It hasn't yet been merged into glibc

Upstream-Status: Pending

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 resolv/res_libc.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/resolv/res_libc.c b/resolv/res_libc.c
index ee3fa21..29e2340 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);
-- 
2.1.4