1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-08-01 10:06:57 +03:00

resolv: Automatically reload a changed /etc/resolv.conf file [BZ #984]

This commit enhances the stub resolver to reload the configuration
in the per-thread _res object if the /etc/resolv.conf file has
changed.  The resolver checks whether the application has modified
_res and will not overwrite the _res object in that case.

The struct resolv_context mechanism is used to check the
configuration file only once per name lookup.
This commit is contained in:
Florian Weimer
2017-07-03 21:06:23 +02:00
parent a1c4eb8794
commit aef16cc8a4
11 changed files with 273 additions and 95 deletions

View File

@ -42,18 +42,6 @@
#include <libc-lock.h>
#include <resolv-internal.h>
/* We have atomic increment operations on 64-bit platforms. */
#if __WORDSIZE == 64
# define atomicinclock(lock) (void) 0
# define atomicincunlock(lock) (void) 0
# define atomicinc(var) catomic_increment (&(var))
#else
__libc_lock_define_initialized (static, lock);
# define atomicinclock(lock) __libc_lock_lock (lock)
# define atomicincunlock(lock) __libc_lock_unlock (lock)
# define atomicinc(var) ++var
#endif
int
res_init (void)
{
@ -90,12 +78,6 @@ res_init (void)
if (!_res.id)
_res.id = res_randomid ();
atomicinclock (lock);
/* Request all threads to re-initialize their resolver states,
resolv.conf might have changed. */
atomicinc (__res_initstamp);
atomicincunlock (lock);
return __res_vinit (&_res, 1);
}