Skip to content

Commit

Permalink
Turn off ipv6 when there is no support at startup.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jar@chromium.org committed Feb 4, 2010
1 parent 9bf6008 commit f6dc896
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions net/base/host_resolver_impl.cc
Expand Up @@ -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;
}

Expand Down
23 changes: 23 additions & 0 deletions net/base/host_resolver_proc.cc
Expand Up @@ -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
3 changes: 3 additions & 0 deletions net/base/host_resolver_proc.h
Expand Up @@ -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>;

Expand Down

0 comments on commit f6dc896

Please sign in to comment.