mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-28 00:21:52 +03:00
Update.
2004-08-04 Jakub Jelinek <jakub@redhat.com> * hesiod/hesiod.c (__hesiod_res_get): Use calloc instead of malloc + memset. (__hesiod_res_set): Free nsaddrs. * include/resolv.h (__res_maybe_init): Add prototype. * resolv/resolv.h (struct __res_state): Add _u._ext.initstamp field. * resolv/Versions (libc): Add __res_maybe_init@@GLIBC_PRIVATE. * resolv/res_libc.c (__res_initstamp, lock): New variables. (res_init): Increase __res_initstamp. (__res_maybe_init): New function. * resolv/res_init.c (__res_vinit): Initialize _u._ext.initstamp. * hesiod/hesiod.c (__hesiod_res_get): Use __res_maybe_init instead of RES_INIT check and {res_ninit,__res_ninit,res_init} call. * sysdeps/posix/getaddrinfo.c (gaih_inet): Likewise. * resolv/nss_dns/dns-host.c (_nss_dns_gethostbyname2_r, _nss_dns_gethostbyaddr_r): Likewise. * resolv/nss_dns/dns-network.c (_nss_dns_getnetbyname_r, _nss_dns_getnetbyaddr_r): Likewise. * resolv/gethnamaddr.c (gethostbyname, gethostbyname2, gethostbyaddr): Likewise. * resolv/res_data.c (fp_nquery, res_mkquery, res_mkupdate, res_isourserver, res_sendsigned, res_update, res_search, res_querydomain): Likewise. * nss/getXXbyYY_r.c (INTERNAL (REENTRANT_NAME)): Likewise. * nss/digits_dots.c (__nss_hostname_digits_dots): Likewise. * nss/getnssent_r.c (__nss_setent, __nss_endent, __nss_getent_r): Likewise. * sysdeps/posix/getaddrinfo.c (gaih_inet): Set ai_family for V4-mapped IPv6 addresses and req->ai_family==AF_INET. Reported by A. Guru <a.guru@sympatico.ca>. * po/pl.po: Likewise. characters than necessary.
This commit is contained in:
@ -15,16 +15,31 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <limits.h>
|
||||
#include <sys/types.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/nameser.h>
|
||||
#include <resolv.h>
|
||||
#include <bits/libc-lock.h>
|
||||
|
||||
|
||||
/* The following bit is copied from res_data.c (where it is #ifdef'ed
|
||||
out) since res_init() should go into libc.so but the rest of that
|
||||
file should not. */
|
||||
|
||||
unsigned long long int __res_initstamp attribute_hidden;
|
||||
/* 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) atomic_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) {
|
||||
extern int __res_vinit(res_state, int);
|
||||
@ -70,8 +85,45 @@ 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));
|
||||
}
|
||||
|
||||
/* Initialize resp if RES_INIT is not yet set or if res_init in some other
|
||||
thread requested re-initializing. */
|
||||
int
|
||||
__res_maybe_init (res_state resp, int preinit)
|
||||
{
|
||||
if (resp->options & RES_INIT) {
|
||||
if (__res_initstamp != resp->_u._ext.initstamp) {
|
||||
if (resp->nscount > 0) {
|
||||
__res_nclose (resp);
|
||||
for (int ns = 0; ns < MAXNS; ns++) {
|
||||
free (resp->_u._ext.nsaddrs[ns]);
|
||||
resp->_u._ext.nsaddrs[ns] = NULL;
|
||||
}
|
||||
return __res_vinit (resp, 1);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
} else if (preinit) {
|
||||
if (!resp->retrans)
|
||||
resp->retrans = RES_TIMEOUT;
|
||||
if (!resp->retry)
|
||||
resp->retry = 4;
|
||||
resp->options = RES_DEFAULT;
|
||||
if (!resp->id)
|
||||
resp->id = res_randomid ();
|
||||
return __res_vinit (resp, 1);
|
||||
} else
|
||||
return __res_ninit (resp);
|
||||
}
|
||||
libc_hidden_def (__res_maybe_init)
|
||||
|
||||
/* This needs to be after the use of _res in res_init, above. */
|
||||
#undef _res
|
||||
|
Reference in New Issue
Block a user