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

Unified Diff: net/base/host_resolver_impl.cc

Issue 6903061: Linux: Monitor resolv.conf for changes and use that to reload resolver. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 9 years, 5 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_impl.cc
diff --git a/net/base/host_resolver_impl.cc b/net/base/host_resolver_impl.cc
index 4898d9e41acad0c27264f884f43c10744feffc90..8f74e2b1e8c08f45609ba5c6f81a2fa5d6388fe1 100644
--- a/net/base/host_resolver_impl.cc
+++ b/net/base/host_resolver_impl.cc
@@ -30,6 +30,7 @@
#include "base/values.h"
#include "net/base/address_list.h"
#include "net/base/address_list_net_log_param.h"
+#include "net/base/dns_reloader.h"
#include "net/base/host_port_pair.h"
#include "net/base/host_resolver_proc.h"
#include "net/base/net_errors.h"
@@ -1111,6 +1112,10 @@ HostResolverImpl::HostResolverImpl(
additional_resolver_flags_ |= HOST_RESOLVER_LOOPBACK_ONLY;
#endif
NetworkChangeNotifier::AddIPAddressObserver(this);
+#if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_OPENBSD)
+ DnsReloaderInit();
+ NetworkChangeNotifier::AddDNSObserver(this);
+#endif
}
HostResolverImpl::~HostResolverImpl() {
@@ -1125,6 +1130,9 @@ HostResolverImpl::~HostResolverImpl() {
cur_completing_job_->Cancel();
NetworkChangeNotifier::RemoveIPAddressObserver(this);
+#if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_OPENBSD)
+ NetworkChangeNotifier::RemoveDNSObserver(this);
+#endif
// Delete the job pools.
for (size_t i = 0u; i < arraysize(job_pools_); ++i)
@@ -1633,4 +1641,17 @@ void HostResolverImpl::OnIPAddressChanged() {
// |this| may be deleted inside AbortAllInProgressJobs().
}
+void HostResolverImpl::OnDNSChanged() {
+ // If the DNS server has changed, existing cached info could be wrong so we
+ // have to drop our internal cache :( Note that OS level DNS caches, such
+ // as NSCD's cache should be dropped automatically by the OS when
+ // resolv.conf changes so we don't need to do anything to clear that cache.
+ if (cache_.get())
+ cache_->clear();
+ // Existing jobs will have been sent to the original server so they need to
+ // be aborted. TODO(Craig): Should these jobs be restarted?
+ AbortAllInProgressJobs();
+ // |this| may be deleted inside AbortAllInProgressJobs().
+}
+
} // namespace net

Powered by Google App Engine
This is Rietveld 408576698