Fix crashes

This commit is contained in:
Mygod
2020-07-03 10:55:21 +08:00
parent 4b1101f41e
commit 05c4ba5b81
10 changed files with 37 additions and 28 deletions

View File

@@ -42,8 +42,9 @@ abstract class RootSession {
}
private suspend fun closeLocked() {
val server = server
this.server = null
server?.close()
server = null
}
private fun startTimeoutLocked() {
check(timeoutJob == null)
@@ -51,8 +52,8 @@ abstract class RootSession {
delay(timeout)
mutex.withLock {
check(usersCount == 0L)
closeLocked()
timeoutJob = null
closeLocked()
}
}
}
@@ -75,14 +76,14 @@ abstract class RootSession {
when {
!server.active -> {
usersCount = 0
closeLocked()
closePending = false
closeLocked()
return@withLock
}
--usersCount > 0L -> return@withLock
closePending -> {
closeLocked()
closePending = false
closeLocked()
}
else -> startTimeoutLocked()
}