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

Unified Diff: net/base/host_resolver_proc.cc

Issue 302010: Add a mechanism to disable IPv6.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Address darin's comments Created 11 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: net/base/host_resolver_proc.cc
===================================================================
--- net/base/host_resolver_proc.cc (revision 29420)
+++ net/base/host_resolver_proc.cc (working copy)
@@ -52,12 +52,13 @@
}
int HostResolverProc::ResolveUsingPrevious(const std::string& host,
+ AddressFamily address_family,
AddressList* addrlist) {
if (previous_proc_)
- return previous_proc_->Resolve(host, addrlist);
+ return previous_proc_->Resolve(host, address_family, addrlist);
// Final fallback is the system resolver.
- return SystemHostResolverProc(host, addrlist);
+ return SystemHostResolverProc(host, address_family, addrlist);
}
#if defined(OS_LINUX)
@@ -124,7 +125,9 @@
#endif // defined(OS_LINUX)
-int SystemHostResolverProc(const std::string& host, AddressList* addrlist) {
+int SystemHostResolverProc(const std::string& host,
+ AddressFamily address_family,
+ AddressList* addrlist) {
// The result of |getaddrinfo| for empty hosts is inconsistent across systems.
// On Windows it gives the default interface's address, whereas on Linux it
// gives an error. We will make it fail on all platforms for consistency.
@@ -133,8 +136,15 @@
struct addrinfo* ai = NULL;
struct addrinfo hints = {0};
- hints.ai_family = AF_UNSPEC;
+ switch (address_family) {
+ case ADDRESS_FAMILY_IPV4_ONLY:
+ hints.ai_family = AF_INET;
+ break;
+ default:
+ hints.ai_family = AF_UNSPEC;
+ }
+
#if defined(OS_WIN)
// DO NOT USE AI_ADDRCONFIG ON WINDOWS.
//

Powered by Google App Engine
This is Rietveld 408576698