Skip to content

Commit

Permalink
Forward channelActive from stream multiplexer. (apple#80)
Browse files Browse the repository at this point in the history
Motivation:

The stream multiplexer was incorrectly eating channelActive on its own
channel, and failing to pass them on to subsequent channel handlers, if
there were any.

Modifications:

- Passed channelActive on from stream multiplexer.

Result:

Easier to handle things on the parent channel.
  • Loading branch information
Lukasa authored and weissi committed Mar 27, 2019
1 parent 85b0868 commit 055b9e5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions Sources/NIOHTTP2/HTTP2StreamMultiplexer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ public final class HTTP2StreamMultiplexer: ChannelInboundHandler, ChannelOutboun
channel.performActivation()
}
}
context.fireChannelActive()
}

public func userInboundEventTriggered(context: ChannelHandlerContext, event: Any) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ extension HTTP2StreamMultiplexerTests {
("testCreatedChildChannelActivatesIfParentIsActive", testCreatedChildChannelActivatesIfParentIsActive),
("testInitiatedChildChannelActivates", testInitiatedChildChannelActivates),
("testMultiplexerIgnoresPriorityFrames", testMultiplexerIgnoresPriorityFrames),
("testMultiplexerForwardsActiveToParent", testMultiplexerForwardsActiveToParent),
]
}
}
Expand Down
16 changes: 16 additions & 0 deletions Tests/NIOHTTP2Tests/HTTP2StreamMultiplexerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1299,4 +1299,20 @@ final class HTTP2StreamMultiplexerTests: XCTestCase {

XCTAssertNoThrow(try self.channel.finish())
}

func testMultiplexerForwardsActiveToParent() throws {
self.channel.addNoOpMultiplexer(mode: .client)

var didActivate = false

let activePromise = self.channel.eventLoop.makePromise(of: Void.self)
activePromise.futureResult.whenSuccess {
didActivate = true
}
XCTAssertNoThrow(try self.channel.pipeline.addHandler(ActiveHandler(activatedPromise: activePromise)).wait())
XCTAssertNoThrow(try self.channel.connect(to: SocketAddress(unixDomainSocketPath: "/nothing")).wait())
XCTAssertTrue(didActivate)

XCTAssertNoThrow(try self.channel.finish())
}
}

0 comments on commit 055b9e5

Please sign in to comment.