Get rid of AI_ADDRCONFIG
Hrvoje Niksic <[email protected]> Fri, 17 Jun 2005 18:47:20 +0200
| Newsgroups | gmane.comp.web.wget.patches |
|---|---|
| Message-ID | <[email protected]> |
This patch removes the use of AI_ADDRCONFIG, for three reasons: 1. It gets confused on systems with IPv6 loopback interfaces, such as modern Linux distributions. 2. It's not really necessary as an optimization, since we reorder the resolved addresses to prefer a family (IPv4 by default) anyway. 3. It's not present everywhere, so we have to handle not having it anyway. 4. (And this was the show-stopper.) It doesn't work at least on AIX 5.1. If using it was a win otherwise, I'd consider blacklisting it on AIX only, but given the points above (especially #2), it's better to just get rid of it. 2005-06-17 Hrvoje Niksic <[email protected]> * connect.c (socket_has_inet6): Removed. * host.c (lookup_host): Don't use the AI_ADDRCONFIG getaddrinfo hint. Index: src/connect.c =================================================================== RCS file: /pack/anoncvs/wget/src/connect.c,v retrieving revision 1.73 diff -u -r1.73 connect.c --- src/connect.c 2005/06/15 20:26:36 1.73 +++ src/connect.c 2005/06/17 16:44:19 @@ -608,37 +608,6 @@ return 1; } -#ifdef ENABLE_IPV6 -# ifndef HAVE_GETADDRINFO_AI_ADDRCONFIG - -/* Return non-zero if the INET6 socket family is supported on the - system. - - This doesn't guarantee that we're able to connect to IPv6 hosts, - but it's better than nothing. It is only used on systems where - getaddrinfo doesn't support AI_ADDRCONFIG. (See lookup_host.) */ - -int -socket_has_inet6 (void) -{ - static int supported = -1; - if (supported == -1) - { - int sock = socket (AF_INET6, SOCK_STREAM, 0); - if (sock < 0) - supported = 0; - else - { - fd_close (sock); - supported = 1; - } - } - return supported; -} - -# endif/* not HAVE_GETADDRINFO_AI_ADDRCONFIG */ -#endif /* ENABLE_IPV6 */ - /* Wait for a single descriptor to become available, timing out after MAXTIME seconds. Returns 1 if FD is available, 0 for timeout and -1 for error. The argument WAIT_FOR can be a combination of Index: src/connect.h =================================================================== RCS file: /pack/anoncvs/wget/src/connect.h,v retrieving revision 1.26 diff -u -r1.26 connect.h --- src/connect.h 2005/05/10 15:17:36 1.26 +++ src/connect.h 2005/06/17 16:44:19 @@ -59,7 +59,6 @@ }; int select_fd PARAMS ((int, double, int)); int test_socket_open PARAMS ((int)); -int socket_has_inet6 PARAMS ((void)); typedef int (*fd_reader_t) PARAMS ((int, char *, int, void *)); typedef int (*fd_writer_t) PARAMS ((int, char *, int, void *)); Index: src/host.c =================================================================== RCS file: /pack/anoncvs/wget/src/host.c,v retrieving revision 1.85 diff -u -r1.85 host.c --- src/host.c 2005/05/14 19:36:29 1.85 +++ src/host.c 2005/06/17 16:44:20 @@ -767,17 +767,11 @@ else if (opt.ipv6_only) hints.ai_family = AF_INET6; else - { + /* We used to specify AI_ADDRCONFIG here, but removed it because + it fails in on systems with IPv6 loopbacks, it loses on AIX + 5.1, and isn't really needed as we sort the addresses). */ hints.ai_family = AF_UNSPEC; -#ifdef AI_ADDRCONFIG - hints.ai_flags |= AI_ADDRCONFIG; -#else - /* On systems without AI_ADDRCONFIG, emulate it by manually - checking whether the system supports IPv6 sockets. */ - if (!socket_has_inet6 ()) - hints.ai_family = AF_INET; -#endif - } + if (flags & LH_BIND) hints.ai_flags |= AI_PASSIVE;