Merge \\"Prepare to delete useless loop in handleReleaseNetworkRequest.\\" into nyc-mr1-dev am: ef9c83a171

am: f035567f74

Change-Id: I68c75cd5980075bdb2586ba5967fcb6ce20dc158
This commit is contained in:
Lorenzo Colitti
2016-07-07 07:49:13 +00:00
committed by android-build-merger

View File

@@ -2448,33 +2448,37 @@ public class ConnectivityService extends IConnectivityManager.Stub
} }
mNetworkRequestInfoLogs.log("RELEASE " + nri); mNetworkRequestInfoLogs.log("RELEASE " + nri);
if (nri.request.isRequest()) { if (nri.request.isRequest()) {
boolean wasKept = false;
NetworkAgentInfo nai = mNetworkForRequestId.get(nri.request.requestId);
if (nai != null) {
nai.removeRequest(nri.request.requestId);
if (VDBG) {
log(" Removing from current network " + nai.name() +
", leaving " + nai.numNetworkRequests() + " requests.");
}
if (unneeded(nai)) {
if (DBG) log("no live requests for " + nai.name() + "; disconnecting");
teardownUnneededNetwork(nai);
} else {
wasKept = true;
}
mNetworkForRequestId.remove(nri.request.requestId);
}
// TODO: remove this code once we know that the Slog.wtf is never hit.
//
// Find all networks that are satisfying this request and remove the request // Find all networks that are satisfying this request and remove the request
// from their request lists. // from their request lists.
// TODO - it's my understanding that for a request there is only a single // TODO - it's my understanding that for a request there is only a single
// network satisfying it, so this loop is wasteful // network satisfying it, so this loop is wasteful
boolean wasKept = false; for (NetworkAgentInfo otherNai : mNetworkAgentInfos.values()) {
for (NetworkAgentInfo nai : mNetworkAgentInfos.values()) { if (otherNai.isSatisfyingRequest(nri.request.requestId) && otherNai != nai) {
if (nai.isSatisfyingRequest(nri.request.requestId)) { Slog.wtf(TAG, "Request " + nri.request + " satisfied by " +
nai.removeRequest(nri.request.requestId); otherNai.name() + ", but mNetworkAgentInfos says " +
if (VDBG) { (nai != null ? nai.name() : "null"));
log(" Removing from current network " + nai.name() +
", leaving " + nai.numNetworkRequests() + " requests.");
}
if (unneeded(nai)) {
if (DBG) log("no live requests for " + nai.name() + "; disconnecting");
teardownUnneededNetwork(nai);
} else {
// suspect there should only be one pass through here
// but if any were kept do the check below
wasKept |= true;
}
} }
} }
NetworkAgentInfo nai = mNetworkForRequestId.get(nri.request.requestId);
if (nai != null) {
mNetworkForRequestId.remove(nri.request.requestId);
}
// Maintain the illusion. When this request arrived, we might have pretended // Maintain the illusion. When this request arrived, we might have pretended
// that a network connected to serve it, even though the network was already // that a network connected to serve it, even though the network was already
// connected. Now that this request has gone away, we might have to pretend // connected. Now that this request has gone away, we might have to pretend