]>
Commit | Line | Data |
---|---|---|
b5aaf4cf AM |
1 | ripped from SuSE |
2 | ||
3 | if /etc/resolv.conf is updated, then make sure applications | |
4 | already running get the updated information. | |
5 | ||
6 | http://bugs.gentoo.org/177416 | |
7 | ||
8 | --- libc/resolv/res_libc.c | |
9 | +++ libc/resolv/res_libc.c | |
10 | @@ -22,6 +22,7 @@ | |
11 | #include <arpa/nameser.h> | |
12 | #include <resolv.h> | |
954aec4b | 13 | #include <libc-lock.h> |
b5aaf4cf AM |
14 | +#include <sys/stat.h> |
15 | ||
16 | ||
17 | /* The following bit is copied from res_data.c (where it is #ifdef'ed | |
18 | @@ -101,6 +102,20 @@ | |
19 | __res_maybe_init (res_state resp, int preinit) | |
20 | { | |
21 | if (resp->options & RES_INIT) { | |
22 | + static time_t last_mtime, last_check; | |
23 | + time_t now; | |
24 | + struct stat statbuf; | |
25 | + | |
26 | + time (&now); | |
27 | + if (now != last_check) { | |
28 | + last_check = now; | |
29 | + if (stat (_PATH_RESCONF, &statbuf) == 0 && last_mtime != statbuf.st_mtime) { | |
30 | + last_mtime = statbuf.st_mtime; | |
31 | + atomicinclock (lock); | |
32 | + atomicinc (__res_initstamp); | |
33 | + atomicincunlock (lock); | |
34 | + } | |
35 | + } | |
36 | if (__res_initstamp != resp->_u._ext.initstamp) { | |
37 | if (resp->nscount > 0) { | |
38 | __res_nclose (resp); |