summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorjar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-04 04:07:59 +0000
committerjar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-04 04:07:59 +0000
commitf6dc8961a5a6dae4bdd32f43d28b3c8efadb8b25 (patch)
tree59b98393eea0bb560fc10a2f974c5d05f226f96a /net
parent9bf60084606921e32d770465b5d704b8fe23ce0b (diff)
downloadchromium_src-f6dc8961a5a6dae4bdd32f43d28b3c8efadb8b25.zip
chromium_src-f6dc8961a5a6dae4bdd32f43d28b3c8efadb8b25.tar.gz
chromium_src-f6dc8961a5a6dae4bdd32f43d28b3c8efadb8b25.tar.bz2
Turn off ipv6 when there is no support at startup.
IPv6 confusion (attempt to support when it is really not supported) has been harming performance, and this may help *some* users that don't have ipv6 support. BUG=12754 r=wtc Review URL: http://codereview.chromium.org/564052 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38078 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/base/host_resolver_impl.cc2
-rw-r--r--net/base/host_resolver_proc.cc23
-rw-r--r--net/base/host_resolver_proc.h3
3 files changed, 28 insertions, 0 deletions
diff --git a/net/base/host_resolver_impl.cc b/net/base/host_resolver_impl.cc
index 94c3857..252df00 100644
--- a/net/base/host_resolver_impl.cc
+++ b/net/base/host_resolver_impl.cc
@@ -53,6 +53,8 @@ HostResolver* CreateSystemHostResolver(
HostResolverImpl* resolver = new HostResolverImpl(
NULL, CreateDefaultCache(), network_change_notifier, kMaxJobs);
+ if (!HostResolverProc::IPv6Supported())
+ resolver->SetDefaultAddressFamily(net::ADDRESS_FAMILY_IPV4);
return resolver;
}
diff --git a/net/base/host_resolver_proc.cc b/net/base/host_resolver_proc.cc
index 5ccf01a..d4e0766 100644
--- a/net/base/host_resolver_proc.cc
+++ b/net/base/host_resolver_proc.cc
@@ -227,4 +227,27 @@ int SystemHostResolverProc(const std::string& host,
return OK;
}
+// TODO(jar): The following is a simple estimate of ipv6 support. We may need
+// to do a test resolution, and a test connection, to REALLY verify support.
+// static
+bool HostResolverProc::IPv6Supported() {
+#if defined(OS_POSIX)
+ int test_socket;
+#else
+ SOCKET test_socket;
+#endif
+
+ test_socket = socket(AF_INET6, SOCK_STREAM, 0);
+ if (test_socket == -1)
+ return false;
+
+#if defined(OS_POSIX)
+ close(test_socket);
+#else
+ closesocket(test_socket);
+#endif
+
+ return true;
+}
+
} // namespace net
diff --git a/net/base/host_resolver_proc.h b/net/base/host_resolver_proc.h
index ca0c55d..343125d 100644
--- a/net/base/host_resolver_proc.h
+++ b/net/base/host_resolver_proc.h
@@ -32,6 +32,9 @@ class HostResolverProc : public base::RefCountedThreadSafe<HostResolverProc> {
AddressFamily address_family,
AddressList* addrlist) = 0;
+ // Test to see if IPv6 is supported.
+ static bool IPv6Supported();
+
protected:
friend class base::RefCountedThreadSafe<HostResolverProc>;