Index: net/base/host_resolver_proc.cc |
=================================================================== |
--- net/base/host_resolver_proc.cc (revision 99676) |
+++ net/base/host_resolver_proc.cc (working copy) |
@@ -8,7 +8,7 @@ |
#include "base/logging.h" |
#include "net/base/address_list.h" |
-#include "net/base/dns_reloader.h" |
+#include "net/base/dns_reload_timer.h" |
#include "net/base/net_errors.h" |
#include "net/base/sys_addrinfo.h" |
@@ -183,12 +183,22 @@ |
// Restrict result set to only this socket type to avoid duplicates. |
hints.ai_socktype = SOCK_STREAM; |
+ int err = getaddrinfo(host.c_str(), NULL, &hints, &ai); |
+ bool should_retry = false; |
#if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_OPENBSD) && \ |
!defined(OS_ANDROID) |
- DnsReloaderMaybeReload(); |
+ // If we fail, re-initialise the resolver just in case there have been any |
+ // changes to /etc/resolv.conf and retry. See http://crbug.com/11380 for info. |
+ if (err && DnsReloadTimerHasExpired()) { |
+ // When there's no network connection, _res may not be initialized by |
+ // getaddrinfo. Therefore, we call res_nclose only when there are ns |
+ // entries. |
+ if (_res.nscount > 0) |
+ res_nclose(&_res); |
+ if (!res_ninit(&_res)) |
+ should_retry = true; |
+ } |
#endif |
- int err = getaddrinfo(host.c_str(), NULL, &hints, &ai); |
- bool should_retry = false; |
// If the lookup was restricted (either by address family, or address |
// detection), and the results where all localhost of a single family, |
// maybe we should retry. There were several bugs related to these |