diff options
author | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-15 04:12:45 +0000 |
---|---|---|
committer | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-15 04:12:45 +0000 |
commit | 8ed0cab69ffa7f19c1e2f9339f93a2e0f33795b5 (patch) | |
tree | 3d8593e0024445d08a82a8e5438c1d4093ffdb15 /net | |
parent | 30b8d3b39c1b433822a59c1034aee729fdf68b46 (diff) | |
download | chromium_src-8ed0cab69ffa7f19c1e2f9339f93a2e0f33795b5.zip chromium_src-8ed0cab69ffa7f19c1e2f9339f93a2e0f33795b5.tar.gz chromium_src-8ed0cab69ffa7f19c1e2f9339f93a2e0f33795b5.tar.bz2 |
Return a distinct error from ERR_NAME_NOT_RESOLVED when the call to getaddrinfo() has unexpectedly failed.
For example when the system returns WSA_NOT_ENOUGH_MEMORY, we will now show ERR_NAME_RESOLUTION_FAILED rather than ERR_NAME_NOT_RESOLVED.
This allows propagating the error to the user, rather than simply showing them say the linkdoctor page as if the domain they entered was incorrect.
The data shows that a small number of users are getting these sorts of unexpected failures, and I want to get more visibility into it. By having a separate error code we can track how often this actually floats up onto an error page (as opposed to just errors on non-essential background requests).
On Linux we also see EAI_AGAIN with some frequency. My theory is that these occur when you DNS resolve immediately after the network change notification was broadcast (since I can repro this 100% on my laptop). If this is in fact the major cause, then once I land this new error we should NOT see an influx of ERR_NAME_RESOLUTION_FAILED in Net.ErrorCodesForMainFrame.
Review URL: http://codereview.chromium.org/3781005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@62705 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/base/host_resolver_impl.cc | 2 | ||||
-rw-r--r-- | net/base/host_resolver_proc.cc | 19 | ||||
-rw-r--r-- | net/base/net_error_list.h | 3 |
3 files changed, 19 insertions, 5 deletions
diff --git a/net/base/host_resolver_impl.cc b/net/base/host_resolver_impl.cc index ffacb22..70f946f 100644 --- a/net/base/host_resolver_impl.cc +++ b/net/base/host_resolver_impl.cc @@ -487,7 +487,7 @@ class HostResolverImpl::Job // Ideally the following code would be part of host_resolver_proc.cc, // however it isn't safe to call NetworkChangeNotifier from worker // threads. So we do it here on the IO thread instead. - if (error_ == ERR_NAME_NOT_RESOLVED && NetworkChangeNotifier::IsOffline()) + if (error_ != OK && NetworkChangeNotifier::IsOffline()) error_ = ERR_INTERNET_DISCONNECTED; base::TimeDelta job_duration = base::TimeTicks::Now() - start_time_; diff --git a/net/base/host_resolver_proc.cc b/net/base/host_resolver_proc.cc index c2235c3..f33195c 100644 --- a/net/base/host_resolver_proc.cc +++ b/net/base/host_resolver_proc.cc @@ -235,13 +235,24 @@ int SystemHostResolverProc(const std::string& host, } if (err) { - if (os_error) { #if defined(OS_WIN) - *os_error = WSAGetLastError(); -#else + err = WSAGetLastError(); +#endif + + // Return the OS error to the caller. + if (os_error) *os_error = err; + + // If the call to getaddrinfo() failed because of a system error, report + // it separately from ERR_NAME_NOT_RESOLVED. +#if defined(OS_WIN) + if (err != WSAHOST_NOT_FOUND && err != WSANO_DATA) + return ERR_NAME_RESOLUTION_FAILED; +#elif defined(OS_POSIX) + if (err != EAI_NONAME && err != EAI_NODATA) + return ERR_NAME_RESOLUTION_FAILED; #endif - } + return ERR_NAME_NOT_RESOLVED; } diff --git a/net/base/net_error_list.h b/net/base/net_error_list.h index 018cd77..d7ae9d1 100644 --- a/net/base/net_error_list.h +++ b/net/base/net_error_list.h @@ -205,6 +205,9 @@ NET_ERROR(SSL_CLIENT_AUTH_CERT_NO_PRIVATE_KEY, -135) // The certificate presented by the HTTPS Proxy was invalid. NET_ERROR(PROXY_CERTIFICATE_INVALID, -136) +// An error occurred when trying to do a name resolution (DNS). +NET_ERROR(NAME_RESOLUTION_FAILED, -137) + // Certificate error codes // // The values of certificate error codes must be consecutive. |