aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2007-06-18 22:22:57 +0000
committerUlrich Drepper <drepper@redhat.com>2007-06-18 22:22:57 +0000
commitae1ad3aebbc397212b4bb2eec92ff19f8c1f913a (patch)
treeb1ec4a328c2f5065d05e19ca024ed9be58dcf28c
parent3abee0b7f15aadf44f442ccdea30f0bdbe113293 (diff)
downloadglibc-ae1ad3aebbc397212b4bb2eec92ff19f8c1f913a.zip
glibc-ae1ad3aebbc397212b4bb2eec92ff19f8c1f913a.tar.gz
glibc-ae1ad3aebbc397212b4bb2eec92ff19f8c1f913a.tar.bz2
[BZ #4647]
Tomas Janousek <tjanouse@redhat.com> Ulrich Drepper <drepper@redhat.com> [BZ #4647] * resolv/res_send.c (send_dg): Remove socket_pf. Use ipv6_unavail member in __res_state, only convaddr4to6 if nssocks[ns] is a PF_INET6 socket. * resolv/resolv.h (__res_state): Add ipv6_unavail member. Make unused member a bitmap. * resolv/res_init.c (__res_vinit): Reset ipv6_unavail if IPv6 servers are configured. 2007-06-18 Jakub Jelinek <jakub@redhat.com>
-rw-r--r--ChangeLog13
-rw-r--r--nptl/ChangeLog8
-rw-r--r--nptl/pthreadP.h3
-rw-r--r--nptl/pthread_mutex_lock.c3
-rw-r--r--nptl/pthread_mutex_timedlock.c3
-rw-r--r--nptl/pthread_mutex_trylock.c3
-rw-r--r--nptl/pthread_mutex_unlock.c3
-rw-r--r--resolv/res_init.c9
-rw-r--r--resolv/res_send.c15
-rw-r--r--resolv/resolv.h6
10 files changed, 51 insertions, 15 deletions
diff --git a/ChangeLog b/ChangeLog
index d04da2c..e75170e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,17 @@
2007-06-18 Jakub Jelinek <jakub@redhat.com>
+ Tomas Janousek <tjanouse@redhat.com>
+ Ulrich Drepper <drepper@redhat.com>
+
+ [BZ #4647]
+ * resolv/res_send.c (send_dg): Remove socket_pf. Use ipv6_unavail
+ member in __res_state, only convaddr4to6 if nssocks[ns] is a PF_INET6
+ socket.
+ * resolv/resolv.h (__res_state): Add ipv6_unavail member. Make
+ unused member a bitmap.
+ * resolv/res_init.c (__res_vinit): Reset ipv6_unavail if IPv6
+ servers are configured.
+
+2007-06-18 Jakub Jelinek <jakub@redhat.com>
* elf/rtld.c (dl_main): Don't call init_tls more than once.
diff --git a/nptl/ChangeLog b/nptl/ChangeLog
index 19f7419..87028ca 100644
--- a/nptl/ChangeLog
+++ b/nptl/ChangeLog
@@ -1,3 +1,11 @@
+2007-06-18 Ulrich Drepper <drepper@redhat.com>
+
+ * pthreadP.h: Define PTHREAD_MUTEX_TYPE.
+ * phtread_mutex_lock.c: Use PTHREAD_MUTEX_TYPE.
+ * pthread_mutex_timedlock.c: Likewise.
+ * pthread_mutex_trylock.c: Likewise.
+ * pthread_mutex_unlock.c: Likewise.
+
2007-06-17 Andreas Schwab <schwab@suse.de>
* sysdeps/pthread/pt-initfini.c: Tell gcc about the nonstandard
diff --git a/nptl/pthreadP.h b/nptl/pthreadP.h
index 46e2476..85fb9b8 100644
--- a/nptl/pthreadP.h
+++ b/nptl/pthreadP.h
@@ -97,6 +97,9 @@ enum
= PTHREAD_MUTEX_PRIO_PROTECT_NP | PTHREAD_MUTEX_ADAPTIVE_NP
};
+#define PTHREAD_MUTEX_TYPE(m) \
+ ((m)->__data.__kind)
+
/* Ceiling in __data.__lock. __data.__lock is signed, so don't
use the MSB bit in there, but in the mask also include that bit,
so that the compiler can optimize & PTHREAD_MUTEX_PRIO_CEILING_MASK
diff --git a/nptl/pthread_mutex_lock.c b/nptl/pthread_mutex_lock.c
index a17013b..d0d6805 100644
--- a/nptl/pthread_mutex_lock.c
+++ b/nptl/pthread_mutex_lock.c
@@ -43,7 +43,8 @@ __pthread_mutex_lock (mutex)
pid_t id = THREAD_GETMEM (THREAD_SELF, tid);
int retval = 0;
- switch (__builtin_expect (mutex->__data.__kind, PTHREAD_MUTEX_TIMED_NP))
+ switch (__builtin_expect (PTHREAD_MUTEX_TYPE (mutex),
+ PTHREAD_MUTEX_TIMED_NP))
{
/* Recursive mutex. */
case PTHREAD_MUTEX_RECURSIVE_NP:
diff --git a/nptl/pthread_mutex_timedlock.c b/nptl/pthread_mutex_timedlock.c
index 74504e4..825a984 100644
--- a/nptl/pthread_mutex_timedlock.c
+++ b/nptl/pthread_mutex_timedlock.c
@@ -37,7 +37,8 @@ pthread_mutex_timedlock (mutex, abstime)
/* We must not check ABSTIME here. If the thread does not block
abstime must not be checked for a valid value. */
- switch (__builtin_expect (mutex->__data.__kind, PTHREAD_MUTEX_TIMED_NP))
+ switch (__builtin_expect (PTHREAD_MUTEX_TYPE (mutex),
+ PTHREAD_MUTEX_TIMED_NP))
{
/* Recursive mutex. */
case PTHREAD_MUTEX_RECURSIVE_NP:
diff --git a/nptl/pthread_mutex_trylock.c b/nptl/pthread_mutex_trylock.c
index 9db904c..9a97a6c 100644
--- a/nptl/pthread_mutex_trylock.c
+++ b/nptl/pthread_mutex_trylock.c
@@ -31,7 +31,8 @@ __pthread_mutex_trylock (mutex)
int oldval;
pid_t id = THREAD_GETMEM (THREAD_SELF, tid);
- switch (__builtin_expect (mutex->__data.__kind, PTHREAD_MUTEX_TIMED_NP))
+ switch (__builtin_expect (PTHREAD_MUTEX_TYPE (mutex),
+ PTHREAD_MUTEX_TIMED_NP))
{
/* Recursive mutex. */
case PTHREAD_MUTEX_RECURSIVE_NP:
diff --git a/nptl/pthread_mutex_unlock.c b/nptl/pthread_mutex_unlock.c
index 1e6b276..642e3a4 100644
--- a/nptl/pthread_mutex_unlock.c
+++ b/nptl/pthread_mutex_unlock.c
@@ -31,7 +31,8 @@ __pthread_mutex_unlock_usercnt (mutex, decr)
{
int newowner = 0;
- switch (__builtin_expect (mutex->__data.__kind, PTHREAD_MUTEX_TIMED_NP))
+ switch (__builtin_expect (PTHREAD_MUTEX_TYPE (mutex),
+ PTHREAD_MUTEX_TIMED_NP))
{
case PTHREAD_MUTEX_RECURSIVE_NP:
/* Recursive mutex. */
diff --git a/resolv/res_init.c b/resolv/res_init.c
index 640e087..d1a5681 100644
--- a/resolv/res_init.c
+++ b/resolv/res_init.c
@@ -241,8 +241,8 @@ __res_vinit(res_state statp, int preinit) {
line[sizeof(name) - 1] == '\t'))
if ((fp = fopen(_PATH_RESCONF, "rc")) != NULL) {
- /* No threads use this stream. */
- __fsetlocking (fp, FSETLOCKING_BYCALLER);
+ /* No threads use this stream. */
+ __fsetlocking (fp, FSETLOCKING_BYCALLER);
/* read the config file */
while (fgets_unlocked(buf, sizeof(buf), fp) != NULL) {
/* skip comments */
@@ -397,8 +397,11 @@ __res_vinit(res_state statp, int preinit) {
if (nserv > 1)
statp->nscount = nserv;
#ifdef _LIBC
- if (nservall - nserv > 0)
+ if (nservall - nserv > 0) {
statp->_u._ext.nscount6 = nservall - nserv;
+ /* We try IPv6 servers again. */
+ statp->ipv6_unavail = false;
+ }
#endif
#ifdef RESOLVSORT
statp->nsort = nsort;
diff --git a/resolv/res_send.c b/resolv/res_send.c
index f38c399..27dd1d4 100644
--- a/resolv/res_send.c
+++ b/resolv/res_send.c
@@ -813,17 +813,20 @@ send_dg(res_state statp,
struct pollfd pfd[1];
int ptimeout;
struct sockaddr_in6 from;
- static int socket_pf = 0;
socklen_t fromlen;
int resplen, seconds, n;
if (EXT(statp).nssocks[ns] == -1) {
/* only try IPv6 if IPv6 NS and if not failed before */
- if ((EXT(statp).nscount6 > 0) && (socket_pf != PF_INET)) {
+ if ((EXT(statp).nscount6 > 0) && !statp->ipv6_unavail) {
EXT(statp).nssocks[ns] =
socket(PF_INET6, SOCK_DGRAM, 0);
- socket_pf = EXT(statp).nssocks[ns] < 0 ? PF_INET
- : PF_INET6;
+ if (EXT(statp).nssocks[ns] < 0)
+ statp->ipv6_unavail = errno == EAFNOSUPPORT;
+ /* If IPv6 socket and nsap is IPv4, make it
+ IPv4-mapped */
+ else if (nsap->sin6_family == AF_INET)
+ convaddr4to6(nsap);
}
if (EXT(statp).nssocks[ns] < 0)
EXT(statp).nssocks[ns] = socket(PF_INET, SOCK_DGRAM, 0);
@@ -832,9 +835,7 @@ send_dg(res_state statp,
Perror(statp, stderr, "socket(dg)", errno);
return (-1);
}
- /* If IPv6 socket and nsap is IPv4, make it IPv4-mapped */
- if ((socket_pf == PF_INET6) && (nsap->sin6_family == AF_INET))
- convaddr4to6(nsap);
+
/*
* On a 4.3BSD+ machine (client and server,
* actually), sending to a nameserver datagram
diff --git a/resolv/resolv.h b/resolv/resolv.h
index 9aa09b8..105631e 100644
--- a/resolv/resolv.h
+++ b/resolv/resolv.h
@@ -110,21 +110,25 @@ struct __res_state {
nsaddr_list[MAXNS]; /* address of name server */
# define nsaddr nsaddr_list[0] /* for backward compatibility */
u_short id; /* current message id */
+ /* 2 byte hole here. */
char *dnsrch[MAXDNSRCH+1]; /* components of domain to search */
char defdname[256]; /* default domain (deprecated) */
u_long pfcode; /* RES_PRF_ flags - see below. */
unsigned ndots:4; /* threshold for initial abs. query */
unsigned nsort:4; /* number of elements in sort_list[] */
- char unused[3];
+ unsigned ipv6_unavail:1; /* connecting to IPv6 server failed */
+ unsigned unused:23;
struct {
struct in_addr addr;
u_int32_t mask;
} sort_list[MAXRESOLVSORT];
+ /* 4 byte hole here on 64-bit architectures. */
res_send_qhook qhook; /* query hook */
res_send_rhook rhook; /* response hook */
int res_h_errno; /* last one set for this context */
int _vcsock; /* PRIVATE: for res_send VC i/o */
u_int _flags; /* PRIVATE: see below */
+ /* 4 byte hole here on 64-bit architectures. */
union {
char pad[52]; /* On an i386 this means 512b total. */
struct {