mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-21 07:56:56 +08:00
Fix cancellation check in AbstractKeepAliveNetworkHandlerSelector
This commit is contained in:
parent
978228afc1
commit
4a2b8ac92c
@ -10,7 +10,10 @@
|
||||
package net.mamoe.mirai.internal.network.handler.selector
|
||||
|
||||
import kotlinx.atomicfu.atomic
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.currentCoroutineContext
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.isActive
|
||||
import kotlinx.coroutines.yield
|
||||
import net.mamoe.mirai.internal.network.handler.NetworkHandler
|
||||
import net.mamoe.mirai.internal.network.handler.NetworkHandlerFactory
|
||||
import net.mamoe.mirai.internal.network.handler.logger
|
||||
@ -87,9 +90,7 @@ internal abstract class AbstractKeepAliveNetworkHandlerSelector<H : NetworkHandl
|
||||
// ?: MaxAttemptsReachedException(null)
|
||||
}
|
||||
if (!currentCoroutineContext().isActive) {
|
||||
logIfEnabled { "Cancellation detected." }
|
||||
yield() // throw canonical CancellationException if cancelled
|
||||
throw CancellationException("Cancellation detected.")
|
||||
yield() // check cancellation
|
||||
}
|
||||
val current = getCurrentInstanceOrNull()
|
||||
lastNetwork = current
|
||||
|
Loading…
Reference in New Issue
Block a user