Do not return dead server from ensureServerLocked
This commit is contained in:
@@ -24,7 +24,11 @@ abstract class RootSession {
|
|||||||
private var closePending = false
|
private var closePending = false
|
||||||
|
|
||||||
private suspend fun ensureServerLocked(): RootServer {
|
private suspend fun ensureServerLocked(): RootServer {
|
||||||
server?.let { return it }
|
server?.let {
|
||||||
|
if (it.active) return it
|
||||||
|
closeLocked()
|
||||||
|
usersCount = 0
|
||||||
|
}
|
||||||
check(usersCount == 0L)
|
check(usersCount == 0L)
|
||||||
val server = createServer()
|
val server = createServer()
|
||||||
try {
|
try {
|
||||||
@@ -42,6 +46,7 @@ abstract class RootSession {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun closeLocked() {
|
private suspend fun closeLocked() {
|
||||||
|
closePending = false
|
||||||
val server = server
|
val server = server
|
||||||
this.server = null
|
this.server = null
|
||||||
server?.close()
|
server?.close()
|
||||||
@@ -76,15 +81,11 @@ abstract class RootSession {
|
|||||||
when {
|
when {
|
||||||
!server.active -> {
|
!server.active -> {
|
||||||
usersCount = 0
|
usersCount = 0
|
||||||
closePending = false
|
|
||||||
closeLocked()
|
closeLocked()
|
||||||
return@withLock
|
return@withLock
|
||||||
}
|
}
|
||||||
--usersCount > 0L -> return@withLock
|
--usersCount > 0L -> return@withLock
|
||||||
closePending -> {
|
closePending -> closeLocked()
|
||||||
closePending = false
|
|
||||||
closeLocked()
|
|
||||||
}
|
|
||||||
else -> startTimeoutLocked()
|
else -> startTimeoutLocked()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -192,7 +192,7 @@ class Routing(private val caller: Any, private val downstream: String) : IpNeigh
|
|||||||
Subrouting(priority, ifname)
|
Subrouting(priority, ifname)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
SmartSnackbar.make(e).show()
|
SmartSnackbar.make(e).show()
|
||||||
Timber.w(e)
|
if (e !is CancellationException) Timber.w(e)
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -221,7 +221,7 @@ class Routing(private val caller: Any, private val downstream: String) : IpNeigh
|
|||||||
Subrouting(priority)
|
Subrouting(priority)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
SmartSnackbar.make(e).show()
|
SmartSnackbar.make(e).show()
|
||||||
Timber.w(e)
|
if (e !is CancellationException) Timber.w(e)
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
dns = listOf(parseNumericAddress("8.8.8.8"))
|
dns = listOf(parseNumericAddress("8.8.8.8"))
|
||||||
|
|||||||
Reference in New Issue
Block a user