mirror of
https://github.com/apple/swift-nio
synced 2026-11-30 05:28:44 +00:00
channelInactive should fire before channelUnregistered
This commit is contained in:
1 parent
3ea35268d4
commit
da905d17f8
3 files changed
+7
-3
No files matched your search
@@ -1145,11 +1145,11 @@ class BaseSocketChannel<T : BaseSocket> : SelectableChannel, ChannelCore {
|
||||
// Fail all pending writes and so ensure all pending promises are notified
|
||||
self.pendingWrites.failAll(error: error)
|
||||
|
||||
pipeline.fireChannelInactive0()
|
||||
|
||||
if !neverRegistered {
|
||||
pipeline.fireChannelUnregistered0()
|
||||
}
|
||||
|
||||
pipeline.fireChannelInactive0()
|
||||
|
||||
eventLoop.execute {
|
||||
// ensure this is executed in a delayed fashion as the users code may still traverse the pipeline
|
||||
|
||||
@@ -98,8 +98,8 @@ class EmbeddedChannelCore : ChannelCore {
|
||||
promise?.succeed(result: ())
|
||||
|
||||
// As we called register() in the constructor of EmbeddedChannel we also need to ensure we call unregistered here.
|
||||
pipeline.fireChannelUnregistered0()
|
||||
pipeline.fireChannelInactive0()
|
||||
pipeline.fireChannelUnregistered0()
|
||||
|
||||
eventLoop.execute {
|
||||
// ensure this is executed in a delayed fashion as the users code may still traverse the pipeline
|
||||
|
||||
@@ -208,6 +208,8 @@ class EchoServerClientTest : XCTestCase {
|
||||
|
||||
public func channelInactive(ctx: ChannelHandlerContext) {
|
||||
if alreadyClosedInChannelInactive.compareAndExchange(expected: false, desired: true) {
|
||||
XCTAssertFalse(self.channelUnregisteredPromise.futureResult.fulfilled,
|
||||
"channelInactive should fire before channelUnregistered")
|
||||
ctx.close().whenComplete { val in
|
||||
switch val {
|
||||
case .failure(ChannelError.alreadyClosed):
|
||||
@@ -224,6 +226,8 @@ class EchoServerClientTest : XCTestCase {
|
||||
|
||||
public func channelUnregistered(ctx: ChannelHandlerContext) {
|
||||
if alreadyClosedInChannelUnregistered.compareAndExchange(expected: false, desired: true) {
|
||||
XCTAssertTrue(self.channelInactivePromise.futureResult.fulfilled,
|
||||
"when channelUnregister fires, channelInactive should already have fired")
|
||||
ctx.close().whenComplete { val in
|
||||
switch val {
|
||||
case .failure(ChannelError.alreadyClosed):
|
||||
|
||||
Reference in new issue
Block a user