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

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

Issue 172061: Don't use the AI_ADDRCONFIG flag on Mac OS X. It's not necessary.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 4 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 | Annotate | Revision Log
« 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_proc.h" 5 #include "net/base/host_resolver_proc.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #if defined(OS_WIN) 9 #if defined(OS_WIN)
10 #include <ws2tcpip.h> 10 #include <ws2tcpip.h>
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 // enable ADDRCONFIG behavior 150 // enable ADDRCONFIG behavior
151 // 151 //
152 // Not only is AI_ADDRCONFIG unnecessary, but it can be harmful. If the 152 // Not only is AI_ADDRCONFIG unnecessary, but it can be harmful. If the
153 // computer is not connected to a network, AI_ADDRCONFIG causes getaddrinfo 153 // computer is not connected to a network, AI_ADDRCONFIG causes getaddrinfo
154 // to fail with WSANO_DATA (11004) for "localhost", probably because of the 154 // to fail with WSANO_DATA (11004) for "localhost", probably because of the
155 // following note on AI_ADDRCONFIG in the MSDN getaddrinfo page: 155 // following note on AI_ADDRCONFIG in the MSDN getaddrinfo page:
156 // The IPv4 or IPv6 loopback address is not considered a valid global 156 // The IPv4 or IPv6 loopback address is not considered a valid global
157 // address. 157 // address.
158 // See http://crbug.com/5234. 158 // See http://crbug.com/5234.
159 hints.ai_flags = 0; 159 hints.ai_flags = 0;
160 #elif defined(OS_MACOSX)
161 // We don't need to use AI_ADDRCONFIG on Mac OS X. There are two evidences:
162 //
163 // 1. The getaddrinfo man page on Mac OS X documents only three flags:
164 // AI_CANONNAME, AI_NUMERICHOST, and AI_PASSIVE, and shows an example that
165 // sets hints.ai_flags to 0.
166 // 2. The <netdb.h> header lists only those three flags in the comment after
167 // the ai_flags field of struct addrinfo, and defines an AI_MASK macro as
168 // the bitwise-OR of those three flags with the comment "valid flags for
169 // addrinfo".
170 //
171 // But is it harmful to use AI_ADDRCONFIG? Unfortunately I can't find a
172 // definitive answer by browsing the getaddrinfo source code in Darwin (in
173 // the Libinfo project).
174 //
175 // See http://crbug.com/12711.
176 hints.ai_flags = 0;
160 #else 177 #else
161 hints.ai_flags = AI_ADDRCONFIG; 178 hints.ai_flags = AI_ADDRCONFIG;
162 #endif 179 #endif
163 180
164 // Restrict result set to only this socket type to avoid duplicates. 181 // Restrict result set to only this socket type to avoid duplicates.
165 hints.ai_socktype = SOCK_STREAM; 182 hints.ai_socktype = SOCK_STREAM;
166 183
167 int err = getaddrinfo(host.c_str(), NULL, &hints, &ai); 184 int err = getaddrinfo(host.c_str(), NULL, &hints, &ai);
168 #if defined(OS_LINUX) 185 #if defined(OS_LINUX)
169 net::DnsReloadTimer* dns_timer = Singleton<net::DnsReloadTimer>::get(); 186 net::DnsReloadTimer* dns_timer = Singleton<net::DnsReloadTimer>::get();
170 // If we fail, re-initialise the resolver just in case there have been any 187 // If we fail, re-initialise the resolver just in case there have been any
171 // changes to /etc/resolv.conf and retry. See http://crbug.com/11380 for info. 188 // changes to /etc/resolv.conf and retry. See http://crbug.com/11380 for info.
172 if (err && dns_timer->Expired()) { 189 if (err && dns_timer->Expired()) {
173 res_nclose(&_res); 190 res_nclose(&_res);
174 if (!res_ninit(&_res)) 191 if (!res_ninit(&_res))
175 err = getaddrinfo(host.c_str(), NULL, &hints, &ai); 192 err = getaddrinfo(host.c_str(), NULL, &hints, &ai);
176 } 193 }
177 #endif 194 #endif
178 195
179 if (err) 196 if (err)
180 return ERR_NAME_NOT_RESOLVED; 197 return ERR_NAME_NOT_RESOLVED;
181 198
182 addrlist->Adopt(ai); 199 addrlist->Adopt(ai);
183 return OK; 200 return OK;
184 } 201 }
185 202
186 } // namespace net 203 } // 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