[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[patches] [PATCH] Reload resolv.conf for all threads
- To: patches@xxxxxxxxxx
- Subject: [patches] [PATCH] Reload resolv.conf for all threads
- From: Aurelien Jarno <aurelien@xxxxxxxxxxx>
- Date: Wed, 15 Sep 2010 02:11:51 +0200
When resolv.conf is modified, the resolver code noticed that and reload
it. However on a multithread program, the thread which notices the
change doesn't ask all the other to re-initialize their resolver. The
patch below fixes the issue.
I submit it here, as this part of the code is EGLIBC specific and not p
art of GLIBC (though present in most distributions).
2010-09-15 Aurelien Jarno <aurelien@xxxxxxxxxxx>
* resolv/res_libc (__res_maybe_init): Ask other threads to
to re-initialize their resolver states when _PATH_RESCONF
changes.
--- a/resolv/res_libc.c
+++ b/resolv/res_libc.c
@@ -100,10 +100,13 @@
if (resp->options & RES_INIT) {
ret = stat (_PATH_RESCONF, &statbuf);
- if ((__res_initstamp != resp->_u._ext.initstamp)
- || ((ret == 0) && (last_mtime != statbuf.st_mtime))) {
- if (ret == 0)
- last_mtime = statbuf.st_mtime;
+ if ((ret == 0) && (last_mtime != statbuf.st_mtime)) {
+ last_mtime = statbuf.st_mtime;
+ atomicinclock (lock);
+ atomicinc (__res_initstamp);
+ atomicincunlock (lock);
+ }
+ if (__res_initstamp != resp->_u._ext.initstamp) {
if (resp->nscount > 0)
__res_iclose (resp, true);
return __res_vinit (resp, 1);
--
Aurelien Jarno GPG: 1024D/F1BCDB73
aurelien@xxxxxxxxxxx http://www.aurel32.net