Prepare to delete useless loop in handleReleaseNetworkRequest.
As explained in the TODO, the loop serves no purpose since only one network can be satisfying a given request at a time. Instead of looping, look up the nai in the mNetworkForRequestId array that exists for this purpose. Keep the loop around with an Slog.wtf statement on it so we can see if we ever hit it, and add a TODO to delete it if we don't. Bug: 23113288 Change-Id: I173de4bd45c5a4169b7a062a981f2ecccaa44143
This commit is contained in:
@@ -2445,13 +2445,9 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
}
|
}
|
||||||
mNetworkRequestInfoLogs.log("RELEASE " + nri);
|
mNetworkRequestInfoLogs.log("RELEASE " + nri);
|
||||||
if (nri.request.isRequest()) {
|
if (nri.request.isRequest()) {
|
||||||
// Find all networks that are satisfying this request and remove the request
|
|
||||||
// from their request lists.
|
|
||||||
// TODO - it's my understanding that for a request there is only a single
|
|
||||||
// network satisfying it, so this loop is wasteful
|
|
||||||
boolean wasKept = false;
|
boolean wasKept = false;
|
||||||
for (NetworkAgentInfo nai : mNetworkAgentInfos.values()) {
|
NetworkAgentInfo nai = mNetworkForRequestId.get(nri.request.requestId);
|
||||||
if (nai.isSatisfyingRequest(nri.request.requestId)) {
|
if (nai != null) {
|
||||||
nai.removeRequest(nri.request.requestId);
|
nai.removeRequest(nri.request.requestId);
|
||||||
if (VDBG) {
|
if (VDBG) {
|
||||||
log(" Removing from current network " + nai.name() +
|
log(" Removing from current network " + nai.name() +
|
||||||
@@ -2461,17 +2457,25 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
if (DBG) log("no live requests for " + nai.name() + "; disconnecting");
|
if (DBG) log("no live requests for " + nai.name() + "; disconnecting");
|
||||||
teardownUnneededNetwork(nai);
|
teardownUnneededNetwork(nai);
|
||||||
} else {
|
} else {
|
||||||
// suspect there should only be one pass through here
|
wasKept = true;
|
||||||
// but if any were kept do the check below
|
|
||||||
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
|
||||||
|
// from their request lists.
|
||||||
|
// TODO - it's my understanding that for a request there is only a single
|
||||||
|
// network satisfying it, so this loop is wasteful
|
||||||
|
for (NetworkAgentInfo otherNai : mNetworkAgentInfos.values()) {
|
||||||
|
if (otherNai.isSatisfyingRequest(nri.request.requestId) && otherNai != nai) {
|
||||||
|
Slog.wtf(TAG, "Request " + nri.request + " satisfied by " +
|
||||||
|
otherNai.name() + ", but mNetworkAgentInfos says " +
|
||||||
|
(nai != null ? nai.name() : "null"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
|
|||||||
Reference in New Issue
Block a user