swift-nio
swift-nio copied to clipboard
NIO can send `channelInactive` before `channelActive` reordered if user `Channel.close()`s in `connect` promise callback
Expected behavior
-
channelInactive
comes afterchannelActive
-
channelInactive
doesn't happen ifchannelActive
hasn't happened
Actual behavior
It's possible to get channelActive
following channelInactive
.
Steps to reproduce
- Create an SSL channel that gets
Channel.close()
d really early on.
This seems related to https://github.com/apple/swift-nio-ssl/issues/467
NIOSSLHandler observes the channel events in this order:
NIOSSLHandler
sees the following channel events:
-
handlerAdded
-
close
(triggered from aChannel.close()
) -
channelInactive
(triggered fromBaseSocketChannel.close0
) [BUG HERE (channelInactive
withoutchannelActive
)] -
channelActive
(triggered fromBaseSocketChannel.writable
->BaseSocketChannel.finishConnect
->BaseSocketChannel.becomeActive()
) [BUG HERE (channelActive
afterchannelInactive
)]
Obviously those channel events are wrong. That's a bug in NIO too.