From 59036ca80de911c6a3f1158c6700d29f9838e883 Mon Sep 17 00:00:00 2001 From: Mygod Date: Fri, 25 Oct 2019 05:12:38 +0800 Subject: [PATCH] Fix race in LOHS --- .../be/mygod/vpnhotspot/LocalOnlyHotspotService.kt | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/LocalOnlyHotspotService.kt b/mobile/src/main/java/be/mygod/vpnhotspot/LocalOnlyHotspotService.kt index f1485d1f..f34e38cf 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/LocalOnlyHotspotService.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/LocalOnlyHotspotService.kt @@ -37,13 +37,12 @@ class LocalOnlyHotspotService : IpNeighbourMonitoringService(), CoroutineScope { val configuration get() = reservation?.wifiConfiguration - fun stop() = when (iface) { - null -> { } // stopped - "" -> { - WifiApManager.cancelLocalOnlyHotspotRequest() - reservation?.close() ?: stopService() + fun stop() { + when (iface) { + null -> return // stopped + "" -> WifiApManager.cancelLocalOnlyHotspotRequest() } - else -> reservation!!.close() + reservation?.close() ?: stopService() } }