DescriptionAvoid initial NetworkChangeNotifier OnDNSChanged() signal on Android
When the DnsConfigServicePosix finishes its initial reading of the
system DNS config, it normally triggers a NetworkChangeNotifier (NCN)
OnDNSChanged() signal. This can cause in-flight network requests to
abort with ERR_NETWORK_CHANGED. Avoid aborting requests by:
1. Adding a new NCN signal, OnInitialDNSConfigRead which indicates
the initial DNS config reading completed but does not represent
a change in DNS config.
2. Modify HostResolverImpl to not abort requests upon this new
signal (like it does for the OnDNSChanged signal).
3. Add logic to NetworkChangeNotifierAndroid to emit this new
signal when safe to do so. Network requests begin being issued
immediately after the NCN (and hence DnsConfigService) is
initialized, so we need to be sure no network change signals
are missed between NCN initialization completing and the
OnInitialDNSConfigRead signal. This is tricky because the
NCN (and hence DnsConfigService) is initialized on threads
where file I/O is not allowed. Were file I/O allowed we could
simply slurp up the DNS config and hosts file. Instead we
start listening for network changes (which is our trigger signal
for DNS changes on Android) on the initialization thread and
record the current time to later compare against the hosts
file's last-modified time to check for changes to the file.
Actual loading of the DNS config and hosts file is done on
another thread that allows file I/O.
BUG=470897
Committed: https://crrev.com/101ed37a9cb2f1a7e906ab9f4e3a1c6331cdf8b3
Cr-Commit-Position: refs/heads/master@{#325560}
Patch Set 1 : #Patch Set 2 : Redo #Patch Set 3 : Cleanup and comment #Patch Set 4 : Tiny cleanup #Patch Set 5 : always use external OnNetworkChanged events #Patch Set 6 : add tests #Patch Set 7 : fix comment #Patch Set 8 : add HostResolverImpl tests #Patch Set 9 : fix tests and appease clang #Patch Set 10 : fix tests when device has no internet #Patch Set 11 : really fix things #Patch Set 12 : fix clang #Patch Set 13 : sync #Patch Set 14 : revert an accidental test enabling #Messages
Total messages: 34 (12 generated)
|