]> sjero.net Git - wget/commitdiff
[svn] Turn on opt.ipv4_only if we're compiling with IPv6, and AI_ADDRINFO is not
authorhniksic <devnull@localhost>
Thu, 13 Nov 2003 16:41:17 +0000 (08:41 -0800)
committerhniksic <devnull@localhost>
Thu, 13 Nov 2003 16:41:17 +0000 (08:41 -0800)
available, and AF_INET6 sockets can't be created.

src/ChangeLog
src/init.c

index 028c0e86f178fabc2aa3c212108ceb84baff38c1..49670ff5c5ebbf1aae3e150f4d26d17740537ef9 100644 (file)
@@ -1,3 +1,9 @@
+2003-11-13  Hrvoje Niksic  <hniksic@xemacs.org>
+
+       * init.c (defaults): Turn on opt.ipv4_only if we're compiling with
+       IPv6, and AI_ADDRINFO is not available, and AF_INET6 sockets can't
+       be created.
+
 2003-11-13  Hrvoje Niksic  <hniksic@xemacs.org>
 
        * host.c (lookup_host): Document the fact that the addresses are
index 182c06485f480283ccb77d29f9f250cf00bdd61a..74e49cc1e63434488065dd2f6b37da141b2ee28c 100644 (file)
@@ -304,6 +304,29 @@ defaults (void)
   opt.restrict_files_os = restrict_windows;
 #endif
   opt.restrict_files_ctrl = 1;
+
+#ifdef ENABLE_IPV6
+# ifndef HAVE_GETADDRINFO_AI_ADDRCONFIG
+  /* If IPv6 is enabled, but AI_ADDRCONFIG is missing, check whether
+     we can create AF_INET6 sockets.  If we can't, turn on the
+     --inet4-only setting.  This is necessary because on some systems
+     (e.g. RHL 9) getaddrinfo resolves AAAA records, but socket()
+     can't even create an AF_INET6 socket, let alone connect to IPv6
+     hosts.  To avoid "address family not supported" error messages,
+     we set ipv4_only.
+
+     We do it as early as here, so that the user can revert the
+     settingn using --no-inet4-only, in case he wants to see the error
+     messages, for whatever reason.  */
+  {
+    int sock = socket (AF_INET6, SOCK_STREAM, 0);
+    if (sock < 0)
+      opt.ipv4_only = 1;
+    else
+      close (sock);
+  }
+# endif /* not HAVE_GETADDRINFO_AI_ADDRCONFIG */
+#endif /* ENABLE_IPV6 */
 }
 \f
 /* Return the user's home directory (strdup-ed), or NULL if none is