summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorszym@chromium.org <szym@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-11 17:12:48 +0000
committerszym@chromium.org <szym@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-11 17:12:48 +0000
commitbe796f726802d6ca440475857d500e4a7f17028e (patch)
tree9698023f0eb00d4b9c356e697ac67eeb876354e7 /net
parent9414c81c9d900b308f137589a02019efc8ca6cd0 (diff)
downloadchromium_src-be796f726802d6ca440475857d500e4a7f17028e.zip
chromium_src-be796f726802d6ca440475857d500e4a7f17028e.tar.gz
chromium_src-be796f726802d6ca440475857d500e4a7f17028e.tar.bz2
[net/dns] Ignore transient flutter of resolv.conf.
Delay the signal from DNS config watchers on POSIX platforms for 50ms. This allows DHCP client to fully apply the options after lease renewal before DnsConfigService attempts to confirm the change. Also extend the allowance to obtain DnsConfig to 150ms to account for measured performance on all platforms. This should extend the tolerance from 97% to 99% of attempts to parse config. BUG=175222,128509 Review URL: https://codereview.chromium.org/12220083 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@181705 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/dns/dns_config_service.cc6
-rw-r--r--net/dns/dns_config_service_posix.cc24
2 files changed, 22 insertions, 8 deletions
diff --git a/net/dns/dns_config_service.cc b/net/dns/dns_config_service.cc
index aa55b13..a22c4eb 100644
--- a/net/dns/dns_config_service.cc
+++ b/net/dns/dns_config_service.cc
@@ -185,10 +185,10 @@ void DnsConfigService::StartTimer() {
// unnecessary Job aborts in HostResolverImpl. The signals come from multiple
// sources so it might receive multiple events during a config change.
- // DHCP and user-induced changes are on the order of seconds, so 100ms should
+ // DHCP and user-induced changes are on the order of seconds, so 150ms should
// not add perceivable delay. On the other hand, config readers should finish
- // within 100ms with the rare exception of I/O block or extra large HOSTS.
- const base::TimeDelta kTimeout = base::TimeDelta::FromMilliseconds(100);
+ // within 150ms with the rare exception of I/O block or extra large HOSTS.
+ const base::TimeDelta kTimeout = base::TimeDelta::FromMilliseconds(150);
timer_.Start(FROM_HERE,
kTimeout,
diff --git a/net/dns/dns_config_service_posix.cc b/net/dns/dns_config_service_posix.cc
index 802ab04..0b80251 100644
--- a/net/dns/dns_config_service_posix.cc
+++ b/net/dns/dns_config_service_posix.cc
@@ -110,14 +110,15 @@ ConfigParsePosixResult ReadDnsConfig(DnsConfig* config) {
class DnsConfigServicePosix::Watcher {
public:
- explicit Watcher(DnsConfigServicePosix* service) : service_(service) {}
+ explicit Watcher(DnsConfigServicePosix* service)
+ : weak_factory_(this),
+ service_(service) {}
~Watcher() {}
bool Watch() {
bool success = true;
- if (!config_watcher_.Watch(
- base::Bind(&DnsConfigServicePosix::OnConfigChanged,
- base::Unretained(service_)))) {
+ if (!config_watcher_.Watch(base::Bind(&Watcher::OnConfigChanged,
+ base::Unretained(this)))) {
LOG(ERROR) << "DNS config watch failed to start.";
success = false;
UMA_HISTOGRAM_ENUMERATION("AsyncDNS.WatchStatus",
@@ -137,10 +138,24 @@ class DnsConfigServicePosix::Watcher {
}
private:
+ void OnConfigChanged(bool succeeded) {
+ // Ignore transient flutter of resolv.conf by delaying the signal a bit.
+ const base::TimeDelta kDelay = base::TimeDelta::FromMilliseconds(50);
+ MessageLoop::current()->PostDelayedTask(
+ FROM_HERE,
+ base::Bind(&Watcher::OnConfigChangedDelayed,
+ weak_factory_.GetWeakPtr(),
+ succeeded),
+ kDelay);
+ }
+ void OnConfigChangedDelayed(bool succeeded) {
+ service_->OnConfigChanged(succeeded);
+ }
void OnHostsChanged(const base::FilePath& path, bool error) {
service_->OnHostsChanged(!error);
}
+ base::WeakPtrFactory<Watcher> weak_factory_;
DnsConfigServicePosix* service_;
ConfigWatcher config_watcher_;
base::FilePathWatcher hosts_watcher_;
@@ -213,7 +228,6 @@ class DnsConfigServicePosix::HostsReader : public SerialWorker {
DnsConfigServicePosix* service_;
const base::FilePath path_;
- const CallbackType callback_;
// Written in DoWork, read in OnWorkFinished, no locking necessary.
DnsHosts hosts_;
bool success_;