diff options
author | wtc@chromium.org <wtc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-15 23:58:55 +0000 |
---|---|---|
committer | wtc@chromium.org <wtc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-15 23:58:55 +0000 |
commit | 6920720802ba0bef2908c562b6eedf2eb6762a64 (patch) | |
tree | 0a4bbd59a8983d0b9b933cb12407e677303f4423 /net | |
parent | afe6ec193c0e36390a366651dd5433fc5123b082 (diff) | |
download | chromium_src-6920720802ba0bef2908c562b6eedf2eb6762a64.zip chromium_src-6920720802ba0bef2908c562b6eedf2eb6762a64.tar.gz chromium_src-6920720802ba0bef2908c562b6eedf2eb6762a64.tar.bz2 |
AI_ADDRCONFIG is not necessary on Windows because its
behavior is ON by default. Using AI_ADDRCONFIG can
actually be harmful, as it causes getaddrinfo to fail
to resolve "localhost" when the computer is not
connected to a network.
R=eroman
http://crbug.com/5234
TEST=See bug 5234 for instructions
Review URL: http://codereview.chromium.org/115424
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16212 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/base/host_resolver.cc | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/net/base/host_resolver.cc b/net/base/host_resolver.cc index a8580fd..27bc787 100644 --- a/net/base/host_resolver.cc +++ b/net/base/host_resolver.cc @@ -40,8 +40,29 @@ HostMapper* SetHostMapper(HostMapper* value) { static int HostResolverProc( const std::string& host, const std::string& port, struct addrinfo** out) { struct addrinfo hints = {0}; - hints.ai_family = PF_UNSPEC; - hints.ai_flags = AI_ADDRCONFIG; + hints.ai_family = AF_UNSPEC; + + // DO NOT USE AI_ADDRCONFIG. + // + // The following comment in <winsock2.h> is the best documentation I found + // on AI_ADDRCONFIG for Windows: + // Flags used in "hints" argument to getaddrinfo() + // - AI_ADDRCONFIG is supported starting with Vista + // - default is AI_ADDRCONFIG ON whether the flag is set or not + // because the performance penalty in not having ADDRCONFIG in + // the multi-protocol stack environment is severe; + // this defaulting may be disabled by specifying the AI_ALL flag, + // in that case AI_ADDRCONFIG must be EXPLICITLY specified to + // enable ADDRCONFIG behavior + // + // Not only is AI_ADDRCONFIG unnecessary, but it can be harmful. If the + // computer is not connected to a network, AI_ADDRCONFIG causes getaddrinfo + // to fail with WSANO_DATA (11004) for "localhost", probably because of the + // following note on AI_ADDRCONFIG in the MSDN getaddrinfo page: + // The IPv4 or IPv6 loopback address is not considered a valid global + // address. + // See http://crbug.com/5234. + hints.ai_flags = 0; // Restrict result set to only this socket type to avoid duplicates. hints.ai_socktype = SOCK_STREAM; |