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

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

Issue 3036011: [Linux] Enable connecting to localhost when offline. (Closed)
Patch Set: Address comments Created 10 years, 5 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_POSIX) && !defined(OS_MACOSX) 9 #if defined(OS_POSIX) && !defined(OS_MACOSX)
10 #include <resolv.h> 10 #include <resolv.h>
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 // The IPv4 or IPv6 loopback address is not considered a valid global 209 // The IPv4 or IPv6 loopback address is not considered a valid global
210 // address. 210 // address.
211 // See http://crbug.com/5234. 211 // See http://crbug.com/5234.
212 // 212 //
213 // OpenBSD does not support it, either. 213 // OpenBSD does not support it, either.
214 hints.ai_flags = 0; 214 hints.ai_flags = 0;
215 #else 215 #else
216 hints.ai_flags = AI_ADDRCONFIG; 216 hints.ai_flags = AI_ADDRCONFIG;
217 #endif 217 #endif
218 218
219 // On Linux AI_ADDRCONFIG doesn't consider loopback addreses, even if only
220 // loopback addresses are configured. So don't use it when there are only
221 // loopback addresses.
222 if (host_resolver_flags & HOST_RESOLVER_LOOPBACK_ONLY)
223 hints.ai_flags &= ~AI_ADDRCONFIG;
224
219 if (host_resolver_flags & HOST_RESOLVER_CANONNAME) 225 if (host_resolver_flags & HOST_RESOLVER_CANONNAME)
220 hints.ai_flags |= AI_CANONNAME; 226 hints.ai_flags |= AI_CANONNAME;
221 227
222 // Restrict result set to only this socket type to avoid duplicates. 228 // Restrict result set to only this socket type to avoid duplicates.
223 hints.ai_socktype = SOCK_STREAM; 229 hints.ai_socktype = SOCK_STREAM;
224 230
225 int err = getaddrinfo(host.c_str(), NULL, &hints, &ai); 231 int err = getaddrinfo(host.c_str(), NULL, &hints, &ai);
226 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_OPENBSD) 232 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_OPENBSD)
227 net::DnsReloadTimer* dns_timer = Singleton<net::DnsReloadTimer>::get(); 233 net::DnsReloadTimer* dns_timer = Singleton<net::DnsReloadTimer>::get();
228 // If we fail, re-initialise the resolver just in case there have been any 234 // If we fail, re-initialise the resolver just in case there have been any
(...skipping 14 matching lines...) Expand all
243 #endif 249 #endif
244 } 250 }
245 return ERR_NAME_NOT_RESOLVED; 251 return ERR_NAME_NOT_RESOLVED;
246 } 252 }
247 253
248 addrlist->Adopt(ai); 254 addrlist->Adopt(ai);
249 return OK; 255 return OK;
250 } 256 }
251 257
252 } // namespace net 258 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698