summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-04 05:34:34 +0000
committerwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-04 05:34:34 +0000
commit08df0f2fc34a4abc51e7d5f5f37bcdaaef82cab6 (patch)
treec192cd878503b7e69f033a32e68e353ae6c667b4 /net
parentd207a5f9ff5af30e4d1dabdeb61c2164a926fd2b (diff)
downloadchromium_src-08df0f2fc34a4abc51e7d5f5f37bcdaaef82cab6.zip
chromium_src-08df0f2fc34a4abc51e7d5f5f37bcdaaef82cab6.tar.gz
chromium_src-08df0f2fc34a4abc51e7d5f5f37bcdaaef82cab6.tar.bz2
Revert "Use res_ninit for thread safety and a timer for reloading resolv.conf on Linux."
This reverts commit d4f0dede964549af67f275ac6296c5e9add3fb03. It caused a valgrind error. TBR=craig.schlenter@gmail.com Review URL: http://codereview.chromium.org/118220 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17607 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/base/host_resolver.cc73
1 files changed, 1 insertions, 72 deletions
diff --git a/net/base/host_resolver.cc b/net/base/host_resolver.cc
index f7f8668..23a1c00 100644
--- a/net/base/host_resolver.cc
+++ b/net/base/host_resolver.cc
@@ -21,12 +21,6 @@
#include "net/base/address_list.h"
#include "net/base/net_errors.h"
-#if defined(OS_LINUX)
-#include "base/singleton.h"
-#include "base/thread_local_storage.h"
-#include "base/time.h"
-#endif
-
#if defined(OS_WIN)
#include "net/base/winsock_init.h"
#endif
@@ -46,70 +40,6 @@ HostMapper* SetHostMapper(HostMapper* value) {
return value;
}
-#if defined(OS_LINUX)
-// On Linux changes to /etc/resolv.conf can go unnoticed thus resulting in
-// DNS queries failing either because nameservers are unknown on startup
-// or because nameserver info has changed as a result of e.g. connecting to
-// a new network. Some distributions patch glibc to stat /etc/resolv.conf
-// to try to automatically detect such changes but these patches are not
-// universal and even patched systems such as Jaunty appear to need calls
-// to res_ninit to reload the nameserver information in different threads.
-//
-// We adopt the Mozilla solution here which is to call res_ninit when
-// lookups fail and to rate limit the reloading to once per second per
-// thread.
-
-// Keep a timer per calling thread to rate limit the calling of res_ninit.
-class DnsReloadTimer {
- public:
- DnsReloadTimer() {
- tls_index_.Initialize(SlotReturnFunction);
- }
-
- ~DnsReloadTimer() { }
-
- // Check if the timer for the calling thread has expired. When no
- // timer exists for the calling thread, create one.
- bool Expired() {
- const base::TimeDelta kRetryTime = base::TimeDelta::FromSeconds(1);
- base::TimeTicks now = base::TimeTicks::Now();
- base::TimeTicks* timer_ptr =
- static_cast<base::TimeTicks*>(tls_index_.Get());
-
- if (!timer_ptr) {
- timer_ptr = new base::TimeTicks();
- *timer_ptr = base::TimeTicks::Now();
- tls_index_.Set(timer_ptr);
- // Return true to reload dns info on the first call for each thread.
- return true;
- } else if (now - *timer_ptr > kRetryTime) {
- *timer_ptr = now;
- return true;
- } else {
- return false;
- }
- }
-
- // Free the allocated timer.
- static void SlotReturnFunction(void* data) {
- base::TimeTicks* tls_data = static_cast<base::TimeTicks*>(data);
- delete tls_data;
- }
-
- private:
- // We use thread local storage to identify which base::TimeTicks to
- // interact with.
- static ThreadLocalStorage::Slot tls_index_ ;
-
- DISALLOW_COPY_AND_ASSIGN(DnsReloadTimer);
-};
-
-// A TLS slot to the TimeTicks for the current thread.
-// static
-ThreadLocalStorage::Slot DnsReloadTimer::tls_index_(base::LINKER_INITIALIZED);
-
-#endif // defined(OS_LINUX)
-
static int HostResolverProc(
const std::string& host, const std::string& port, struct addrinfo** out) {
struct addrinfo hints = {0};
@@ -146,10 +76,9 @@ static int HostResolverProc(
int err = getaddrinfo(host.c_str(), port.c_str(), &hints, out);
#if defined(OS_LINUX)
- net::DnsReloadTimer* dns_timer = Singleton<net::DnsReloadTimer>::get();
// 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 && dns_timer->Expired() && !res_ninit(&_res))
+ if (err && !res_init())
err = getaddrinfo(host.c_str(), port.c_str(), &hints, out);
#endif