Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1097)

Side by Side Diff: net/base/host_resolver.cc

Issue 112057: Backport r16212 and r16695 from the trunk to the 172... (Closed) Base URL: svn://chrome-svn.corp.google.com/chrome/branches/172/src/
Patch Set: Created 11 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/base/host_resolver.h" 5 #include "net/base/host_resolver.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <ws2tcpip.h> 8 #include <ws2tcpip.h>
9 #include <wspiapi.h> // Needed for Win2k compat. 9 #include <wspiapi.h> // Needed for Win2k compat.
10 #elif defined(OS_POSIX) 10 #elif defined(OS_POSIX)
(...skipping 22 matching lines...) Expand all
33 } 33 }
34 34
35 HostMapper* SetHostMapper(HostMapper* value) { 35 HostMapper* SetHostMapper(HostMapper* value) {
36 std::swap(host_mapper, value); 36 std::swap(host_mapper, value);
37 return value; 37 return value;
38 } 38 }
39 39
40 static int HostResolverProc( 40 static int HostResolverProc(
41 const std::string& host, const std::string& port, struct addrinfo** out) { 41 const std::string& host, const std::string& port, struct addrinfo** out) {
42 struct addrinfo hints = {0}; 42 struct addrinfo hints = {0};
43 hints.ai_family = PF_UNSPEC; 43 hints.ai_family = AF_UNSPEC;
44
45 #if defined(OS_WIN)
46 // DO NOT USE AI_ADDRCONFIG ON WINDOWS.
47 //
48 // The following comment in <winsock2.h> is the best documentation I found
49 // on AI_ADDRCONFIG for Windows:
50 // Flags used in "hints" argument to getaddrinfo()
51 // - AI_ADDRCONFIG is supported starting with Vista
52 // - default is AI_ADDRCONFIG ON whether the flag is set or not
53 // because the performance penalty in not having ADDRCONFIG in
54 // the multi-protocol stack environment is severe;
55 // this defaulting may be disabled by specifying the AI_ALL flag,
56 // in that case AI_ADDRCONFIG must be EXPLICITLY specified to
57 // enable ADDRCONFIG behavior
58 //
59 // Not only is AI_ADDRCONFIG unnecessary, but it can be harmful. If the
60 // computer is not connected to a network, AI_ADDRCONFIG causes getaddrinfo
61 // to fail with WSANO_DATA (11004) for "localhost", probably because of the
62 // following note on AI_ADDRCONFIG in the MSDN getaddrinfo page:
63 // The IPv4 or IPv6 loopback address is not considered a valid global
64 // address.
65 // See http://crbug.com/5234.
66 hints.ai_flags = 0;
67 #else
44 hints.ai_flags = AI_ADDRCONFIG; 68 hints.ai_flags = AI_ADDRCONFIG;
69 #endif
45 70
46 // Restrict result set to only this socket type to avoid duplicates. 71 // Restrict result set to only this socket type to avoid duplicates.
47 hints.ai_socktype = SOCK_STREAM; 72 hints.ai_socktype = SOCK_STREAM;
48 73
49 int err = getaddrinfo(host.c_str(), port.c_str(), &hints, out); 74 int err = getaddrinfo(host.c_str(), port.c_str(), &hints, out);
50 return err ? ERR_NAME_NOT_RESOLVED : OK; 75 return err ? ERR_NAME_NOT_RESOLVED : OK;
51 } 76 }
52 77
53 static int ResolveAddrInfo(HostMapper* mapper, const std::string& host, 78 static int ResolveAddrInfo(HostMapper* mapper, const std::string& host,
54 const std::string& port, struct addrinfo** out) { 79 const std::string& port, struct addrinfo** out) {
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 NewRunnableMethod(request_.get(), &Request::DoLookup), true)) { 224 NewRunnableMethod(request_.get(), &Request::DoLookup), true)) {
200 NOTREACHED(); 225 NOTREACHED();
201 request_ = NULL; 226 request_ = NULL;
202 return ERR_FAILED; 227 return ERR_FAILED;
203 } 228 }
204 229
205 return ERR_IO_PENDING; 230 return ERR_IO_PENDING;
206 } 231 }
207 232
208 } // namespace net 233 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698