Fix keepalive don't get removed when lower layer error

Currently, if the lower layer, e.g. wifi, didn't successfully
start keepalive by any reason. Due to the startedState changed
to NOT_STARTED first, the logic inside stop() will skip the
removing process and cause leak.

Thus, moving the changing of startedState to proper place first
to unblock subsequent changes first.

Bug: 123988249
Bug: 129371366
Test: atest FrameworksNetTests
Change-Id: I4bba01bacc80e1dac2023ef831b5ade5501894e4
This commit is contained in:
junyulai
2019-03-27 10:31:11 +08:00
parent 06bdf061f0
commit 422a3c1448

View File

@@ -480,7 +480,6 @@ public class KeepaliveTracker {
}
} else {
// Keepalive successfully stopped, or error.
ki.mStartedState = KeepaliveInfo.NOT_STARTED;
if (reason == SUCCESS) {
// The message indicated success stopping : don't call handleStopKeepalive.
if (DBG) Log.d(TAG, "Successfully stopped keepalive " + slot + " on " + nai.name());
@@ -490,6 +489,7 @@ public class KeepaliveTracker {
handleStopKeepalive(nai, slot, reason);
if (DBG) Log.d(TAG, "Keepalive " + slot + " on " + nai.name() + " error " + reason);
}
ki.mStartedState = KeepaliveInfo.NOT_STARTED;
}
}