Skip to content
Commit 6dea37dc authored by Iris Chang's avatar Iris Chang
Browse files

Fix RouterAdvertisementDaemon thread leakage problem

[Prerequisites]
Default value of mRaLength is 0, so getNextMulticastTransmitDelaySec()
returns DAY_IN_SECONDS (1 day) in this scenario.

[Issue Details]
Examine MulticastTransmitter.run() for detail:

676        public void run() {
677            while (isSocketValid()) {
678                try {
679                    Thread.sleep(getNextMulticastTransmitDelayMs());

Invoke RouterAdvertisementDaemon.stop() here. Since MulticastTransmitter
is in a sleep, this thread will pend 1 day until the next check of
isSocketValid() triggers the quit action, which causes thread leakage
during Wi-Fi Hotspot on/off stress test.

680                } catch (InterruptedException ignored) {

[Solution]
Invoke maybeNotifyMulticastTransmitter() after closing socket in
RouterAdvertisementDaemon.stop() to interrupt MulticastTransmitter from
waiting.

Bug: 123491872
Test: FrameworksNetTests
  adb shell am instrument -w com.android.frameworks.tests.net
Test: CTS - CtsNetTestCases
  ANDROID_BUILD_droid-cts/tools/cts-tradefed run cts -m CtsNetTestCases
Test: CTS - CtsNetTestCasesLegacyApi22
  ANDROID_BUILD_droid-cts/tools/cts-tradefed run cts -m
  CtsNetTestCasesLegacyApi22
Test: CTS - CtsNetTestCasesLegacyPermission22
  ANDROID_BUILD_droid-cts/tools/cts-tradefed run cts -m
  CtsNetTestCasesLegacyPermission22

Change-Id: I0c0d63b43a88e1026aaecfc1853309ad63f62268
parent 5cf41e47
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment