Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5d7bb8b4 authored by junyulai's avatar junyulai Committed by Junyu Lai
Browse files

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
parent 990053e5
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -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) {