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

Commit 8246ca02 authored by Junyu Lai's avatar Junyu Lai Committed by junyulai
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: Id3e4e159713c0ed7e03f45169e87b73ae6408e4f
(cherry picked from commit a5f6bd16)
Merged-In: Id3e4e159713c0ed7e03f45169e87b73ae6408e4f
Merged-In: Icb5a1b5bb10617aa5a7b35db6cf48db3dc53b7fd
parent fd850fd3
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -462,6 +462,9 @@ 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