Log the OS error that getaddrinfo() failed with.
- Display it on the about:net-internals page
- Collect it in the histogram Net.OSErrorsForGetAddrinfo.
Review URL: http://codereview.chromium.org/2134004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47386 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/net/base/host_resolver_proc.cc b/net/base/host_resolver_proc.cc
index 84daae0..804135c 100644
--- a/net/base/host_resolver_proc.cc
+++ b/net/base/host_resolver_proc.cc
@@ -71,14 +71,16 @@
const std::string& host,
AddressFamily address_family,
HostResolverFlags host_resolver_flags,
- AddressList* addrlist) {
- if (previous_proc_)
- return previous_proc_->Resolve(host, address_family,
- host_resolver_flags, addrlist);
+ AddressList* addrlist,
+ int* os_error) {
+ if (previous_proc_) {
+ return previous_proc_->Resolve(host, address_family, host_resolver_flags,
+ addrlist, os_error);
+ }
// Final fallback is the system resolver.
- return SystemHostResolverProc(host, address_family,
- host_resolver_flags, addrlist);
+ return SystemHostResolverProc(host, address_family, host_resolver_flags,
+ addrlist, os_error);
}
#if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_OPENBSD)
@@ -157,7 +159,11 @@
int SystemHostResolverProc(const std::string& host,
AddressFamily address_family,
HostResolverFlags host_resolver_flags,
- AddressList* addrlist) {
+ AddressList* addrlist,
+ int* os_error) {
+ if (os_error)
+ *os_error = 0;
+
// 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.
@@ -228,8 +234,16 @@
}
#endif
- if (err)
+ if (err) {
+ if (os_error) {
+#if defined(OS_WIN)
+ *os_error = WSAGetLastError();
+#else
+ *os_error = err;
+#endif
+ }
return ERR_NAME_NOT_RESOLVED;
+ }
addrlist->Adopt(ai);
return OK;