diff --git a/mobile/src/main/java/be/mygod/librootkotlinx/RootSession.kt b/mobile/src/main/java/be/mygod/librootkotlinx/RootSession.kt index eba484e9..728de2a1 100644 --- a/mobile/src/main/java/be/mygod/librootkotlinx/RootSession.kt +++ b/mobile/src/main/java/be/mygod/librootkotlinx/RootSession.kt @@ -24,7 +24,11 @@ abstract class RootSession { private var closePending = false private suspend fun ensureServerLocked(): RootServer { - server?.let { return it } + server?.let { + if (it.active) return it + closeLocked() + usersCount = 0 + } check(usersCount == 0L) val server = createServer() try { @@ -42,6 +46,7 @@ abstract class RootSession { } private suspend fun closeLocked() { + closePending = false val server = server this.server = null server?.close() @@ -76,15 +81,11 @@ abstract class RootSession { when { !server.active -> { usersCount = 0 - closePending = false closeLocked() return@withLock } --usersCount > 0L -> return@withLock - closePending -> { - closePending = false - closeLocked() - } + closePending -> closeLocked() else -> startTimeoutLocked() } } diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/net/Routing.kt b/mobile/src/main/java/be/mygod/vpnhotspot/net/Routing.kt index 52a5720f..4b4f1805 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/net/Routing.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/net/Routing.kt @@ -192,7 +192,7 @@ class Routing(private val caller: Any, private val downstream: String) : IpNeigh Subrouting(priority, ifname) } catch (e: Exception) { SmartSnackbar.make(e).show() - Timber.w(e) + if (e !is CancellationException) Timber.w(e) null } } @@ -221,7 +221,7 @@ class Routing(private val caller: Any, private val downstream: String) : IpNeigh Subrouting(priority) } catch (e: Exception) { SmartSnackbar.make(e).show() - Timber.w(e) + if (e !is CancellationException) Timber.w(e) null } dns = listOf(parseNumericAddress("8.8.8.8"))