1
0
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:
Him188 2022-06-05 12:26:17 +01:00
parent 4de2f54f92
commit ca1043e7ff
No known key found for this signature in database
GPG Key ID: BA439CDDCF652375
4 changed files with 1 additions and 10 deletions
mirai-core/src
commonMain/kotlin/network/handler
commonTest/kotlin/network/framework
jvmBaseTest/kotlin/network/framework
nativeTest/kotlin/network/framework

View File

@ -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 {

View File

@ -100,8 +100,6 @@ internal expect abstract class AbstractCommonNHTest() :
val conn: PlatformConn
override val network: TestCommonNetworkHandler
override val factory: NetworkHandlerFactory<TestCommonNetworkHandler>
protected fun removeOutgoingPacketEncoder()

View File

@ -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>()

View File

@ -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) {