This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] [BZ #20900] Call __res_vinit if _PATH_RESCONF is changed
- From: Andreas Schwab <schwab at linux-m68k dot org>
- To: "H.J. Lu" <hongjiu dot lu at intel dot com>
- Cc: GNU C Library <libc-alpha at sourceware dot org>, "H.J. Lu" <hjl dot tools at gmail dot com>
- Date: Thu, 01 Dec 2016 20:21:50 +0100
- Subject: Re: [PATCH] [BZ #20900] Call __res_vinit if _PATH_RESCONF is changed
- Authentication-results: sourceware.org; auth=none
- References: <20161201185641.GA15507@intel.com>
On Dez 01 2016, "H.J. Lu" <hongjiu.lu@intel.com> wrote:
> @@ -97,6 +98,21 @@ __res_maybe_init (res_state resp, int preinit)
> if (resp->nscount > 0)
> __res_iclose (resp, true);
> return __res_vinit (resp, 1);
> + } else {
> + struct stat buf;
> +
> + /* Call __res_vinit if _PATH_RESCONF has been
> + changed since the last time. */
> + if (stat (_PATH_RESCONF, &buf) == 0) {
> + static struct timespec mtime;
> + if (mtime.tv_sec != buf.st_mtim.tv_sec
> + || mtime.tv_nsec != buf.st_mtim.tv_nsec) {
> + mtime = buf.st_mtim;
> + if (resp->nscount > 0)
> + __res_iclose (resp, true);
> + return __res_vinit (resp, 1);
This isn't thread-safe.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."