mirror of
https://github.com/mamoe/mirai.git
synced 2025-04-09 02:10:10 +08:00
Always close NetworkHandlerSupport even if CommonNetworkHandler is in CLOSED state
This commit is contained in:
parent
4de2f54f92
commit
ca1043e7ff
mirai-core/src
commonMain/kotlin/network/handler
commonTest/kotlin/network/framework
jvmBaseTest/kotlin/network/framework
nativeTest/kotlin/network/framework
@ -162,9 +162,9 @@ internal abstract class CommonNetworkHandler<Conn>(
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
override fun close(cause: Throwable?) {
|
||||
super.close(cause) // cancel coroutine scope
|
||||
if (state == NetworkHandler.State.CLOSED) return // quick check if already closed
|
||||
if (setState { StateClosed(cause) } == null) return // atomic check
|
||||
super.close(cause) // cancel coroutine scope
|
||||
}
|
||||
|
||||
init {
|
||||
|
@ -100,8 +100,6 @@ internal expect abstract class AbstractCommonNHTest() :
|
||||
|
||||
val conn: PlatformConn
|
||||
|
||||
override val network: TestCommonNetworkHandler
|
||||
|
||||
override val factory: NetworkHandlerFactory<TestCommonNetworkHandler>
|
||||
|
||||
protected fun removeOutgoingPacketEncoder()
|
||||
|
@ -20,9 +20,6 @@ import kotlin.test.AfterTest
|
||||
*/
|
||||
internal actual abstract class AbstractCommonNHTest actual constructor() :
|
||||
AbstractRealNetworkHandlerTest<TestCommonNetworkHandler>() {
|
||||
actual override val network: TestCommonNetworkHandler by lazy {
|
||||
factory.create(createContext(), createAddress())
|
||||
}
|
||||
|
||||
private val startedDispatchers = mutableListOf<ExecutorCoroutineDispatcher>()
|
||||
|
||||
|
@ -19,10 +19,6 @@ import net.mamoe.mirai.internal.network.handler.NetworkHandlerFactory
|
||||
internal actual abstract class AbstractCommonNHTest actual constructor() :
|
||||
AbstractRealNetworkHandlerTest<TestCommonNetworkHandler>() {
|
||||
|
||||
actual override val network: TestCommonNetworkHandler by lazy {
|
||||
factory.create(createContext(), createAddress())
|
||||
}
|
||||
|
||||
actual override val factory: NetworkHandlerFactory<TestCommonNetworkHandler> =
|
||||
NetworkHandlerFactory<TestCommonNetworkHandler> { context, address ->
|
||||
object : TestCommonNetworkHandler(bot, context, address) {
|
||||
|
Loading…
Reference in New Issue
Block a user