On Sat, Apr 18, 2015 at 01:49:57PM -0600, Philip Prindeville wrote:
If you go back through the previous glibc bugs, you'll find:
https://sourceware.org/bugzilla/show_bug.cgi?id=984
from 2005 which was closed out as "RESOLVED, WONTFIX" with the text:
There is a solution, already implemented.
Use nscd and nscd -i hosts in the script that rewrites your resolv.conf
(or nsswitch.conf etc.).
Yes, that has been the upstream stance since quite some time now, so I
don't know if filing a fresh bug would change that. You could however
start a discussion upstream (libc-alpha at sourceware dot org) and
make a case for the resolver to watch for changes in resolv.conf.
Problem with that is that no one seems to have gravitated towards
this solution, and I don't blame them. It adds an extra layer of
complexity and makes debugging issues that much more murky.
A simpler fix is to grab mtime from stat()ing _PATH_RESCONF each
time through res_query() and see if it's changed since the last
time. Perhaps caching the inode # also and checking that, since an
older version of the file might have been renamed as
/etc/resolv.conf.
That is conceptually simple, but expensive, since you'll be adding
syscalls to every lookup. One may argue that it is not much overhead
for a network lookup since the latter will still take up a bulk of the
time, but it is an added cost nevertheless.
Siddhesh