[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [patches] [PATCH] Reload resolv.conf for all threads
- To: Aurelien Jarno <aurelien@xxxxxxxxxxx>
- Subject: Re: [patches] [PATCH] Reload resolv.conf for all threads
- From: Maxim Kuvyrkov <maxim@xxxxxxxxxxxxxxxx>
- Date: Thu, 16 Sep 2010 20:05:33 +0400
On 9/15/10 4:11 AM, Aurelien Jarno wrote:
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).
Michael (CC'ed) is the author of the code in question.
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);
This looks correct to me. Michael, do you have any comments?
--
Maxim Kuvyrkov
CodeSourcery
maxim@xxxxxxxxxxxxxxxx
(650) 331-3385 x724