diff options
author | Ulrich Drepper <drepper@redhat.com> | 2007-06-18 22:22:57 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2007-06-18 22:22:57 +0000 |
commit | ae1ad3aebbc397212b4bb2eec92ff19f8c1f913a (patch) | |
tree | b1ec4a328c2f5065d05e19ca024ed9be58dcf28c /resolv/res_send.c | |
parent | 3abee0b7f15aadf44f442ccdea30f0bdbe113293 (diff) | |
download | glibc-ae1ad3aebbc397212b4bb2eec92ff19f8c1f913a.tar.gz glibc-ae1ad3aebbc397212b4bb2eec92ff19f8c1f913a.tar.xz glibc-ae1ad3aebbc397212b4bb2eec92ff19f8c1f913a.zip |
[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>
Diffstat (limited to 'resolv/res_send.c')
-rw-r--r-- | resolv/res_send.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/resolv/res_send.c b/resolv/res_send.c index f38c399ffd..27dd1d4351 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 |