diff options
| author | 2014-12-15 11:56:18 -0500 | |
|---|---|---|
| committer | 2014-12-15 15:20:30 -0500 | |
| commit | f4ffaa4f57a8af4452f27e47ca65ee85fa0a60dc (patch) | |
| tree | 102faae217b6a2aa58b88fe4e15733257eaaf69f | |
| parent | d6fc7cf149795abdcd0629e229be52b816ee13c1 (diff) | |
Fix race between CONNECTIVITY_ACTION and setting default network.
Now that the delay between connectivity changes and CONNECTIVITY_ACTION
has been removed (ag/599650) races between CONNECTIVITY_ACTION and
the setting of the default network become more evident.
In http://crbug.com/441818 Chrome is calling getaddrinfo()
immediately after a device goes from no connectivity to cellular
connectivity, and Chrome is erroneously getting back EAI_NODATA
because netd hasn't yet set the default network for DNS resolutions.
bug:18757162
Change-Id: Ib607dcb3697403272a8c838713a9cb602e9c6820
| -rw-r--r-- | services/core/java/com/android/server/ConnectivityService.java | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java index 499cff3dbda2..788b5d355259 100644 --- a/services/core/java/com/android/server/ConnectivityService.java +++ b/services/core/java/com/android/server/ConnectivityService.java @@ -3949,6 +3949,7 @@ public class ConnectivityService extends IConnectivityManager.Stub notifyLockdownVpn(newNetwork); handleApplyDefaultProxy(newNetwork.linkProperties.getHttpProxy()); updateTcpBufferSizes(newNetwork); + setDefaultDnsSystemProperties(newNetwork.linkProperties.getDnsServers()); } // Handles a network appearing or improving its score. @@ -3988,6 +3989,7 @@ public class ConnectivityService extends IConnectivityManager.Stub } boolean keep = newNetwork.isVPN(); boolean isNewDefault = false; + NetworkAgentInfo oldDefaultNetwork = null; if (DBG) log("rematching " + newNetwork.name()); // Find and migrate to this Network any NetworkRequests for // which this network is now the best. @@ -4045,25 +4047,7 @@ public class ConnectivityService extends IConnectivityManager.Stub sendUpdatedScoreToFactories(nri.request, newNetwork.getCurrentScore()); if (mDefaultRequest.requestId == nri.request.requestId) { isNewDefault = true; - // TODO: Remove following line. It's redundant with makeDefault call. - if (newNetwork.linkProperties != null) { - updateTcpBufferSizes(newNetwork); - setDefaultDnsSystemProperties( - newNetwork.linkProperties.getDnsServers()); - } else { - setDefaultDnsSystemProperties(new ArrayList<InetAddress>()); - } - // Maintain the illusion: since the legacy API only - // understands one network at a time, we must pretend - // that the current default network disconnected before - // the new one connected. - if (currentNetwork != null) { - mLegacyTypeTracker.remove(currentNetwork.networkInfo.getType(), - currentNetwork); - } - mDefaultInetConditionPublished = newNetwork.validated ? 100 : 0; - mLegacyTypeTracker.add(newNetwork.networkInfo.getType(), newNetwork); - notifyLockdownVpn(newNetwork); + oldDefaultNetwork = currentNetwork; } } } @@ -4104,6 +4088,17 @@ public class ConnectivityService extends IConnectivityManager.Stub 1000); } } + // Maintain the illusion: since the legacy API only + // understands one network at a time, we must pretend + // that the current default network disconnected before + // the new one connected. + if (oldDefaultNetwork != null) { + mLegacyTypeTracker.remove(oldDefaultNetwork.networkInfo.getType(), + oldDefaultNetwork); + } + mDefaultInetConditionPublished = newNetwork.validated ? 100 : 0; + mLegacyTypeTracker.add(newNetwork.networkInfo.getType(), newNetwork); + notifyLockdownVpn(newNetwork); } // Notify battery stats service about this network, both the normal |