From 782e216494ea788c9266a8042485490908434aca Mon Sep 17 00:00:00 2001 From: junyulai Date: Thu, 25 Apr 2019 11:24:04 +0800 Subject: [PATCH] Clean up the keepalive slots when network disconnect In general, keepalive slots are released after result of stopping has returned. However, for network disconnect case, the service side cannot communicate with network agent since the async channel is broken. Clean up keepalive slots right after stop in this case. Bug: 132341736 Test: 1. atest com.android.server.ConnectivityServiceTest \ #testNattSocketKeepalives --generate-new-metrics 100 2. atest FrameworksNetTests --generate-new-metrics 10 Change-Id: Ia30741f71fa72fc117e071976fd73991fa3c9535 --- .../com/android/server/connectivity/KeepaliveTracker.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/services/core/java/com/android/server/connectivity/KeepaliveTracker.java b/services/core/java/com/android/server/connectivity/KeepaliveTracker.java index bde430cc29..84887bdb2d 100644 --- a/services/core/java/com/android/server/connectivity/KeepaliveTracker.java +++ b/services/core/java/com/android/server/connectivity/KeepaliveTracker.java @@ -496,10 +496,11 @@ public class KeepaliveTracker { if (networkKeepalives != null) { for (KeepaliveInfo ki : networkKeepalives.values()) { ki.stop(reason); + // Clean up keepalives since the network agent is disconnected and unable to pass + // back asynchronous result of stop(). + cleanupStoppedKeepalive(nai, ki.mSlot); } } - // Clean up keepalives will be done as a result of calling ki.stop() after the slots are - // freed. } public void handleStopKeepalive(NetworkAgentInfo nai, int slot, int reason) {