mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-04 07:44:42 +08:00
Always close netty connection if StateLoading completed with an exception
This commit is contained in:
parent
91b5a5da58
commit
e9c53eb5db
@ -39,6 +39,7 @@ internal open class NettyNetworkHandler(
|
||||
private val address: SocketAddress,
|
||||
) : NetworkHandlerSupport(context) {
|
||||
override fun close(cause: Throwable?) {
|
||||
if (state == State.CLOSED) return // already
|
||||
setState { StateClosed(CancellationException("Closed manually.", cause)) }
|
||||
super.close(cause)
|
||||
// wrap an exception, more stacktrace information
|
||||
@ -310,9 +311,8 @@ internal open class NettyNetworkHandler(
|
||||
) : NettyState(State.LOADING) {
|
||||
init {
|
||||
coroutineContext.job.invokeOnCompletion {
|
||||
if (it != null && it !is CancellationException && it !is StateSwitchingException) {
|
||||
if (it != null) {
|
||||
connection.close()
|
||||
setState { StateClosed(it) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user