Do not return dead server from ensureServerLocked
This commit is contained in:
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"))
|
||||
|
||||
Reference in New Issue
Block a user