-
Notifications
You must be signed in to change notification settings - Fork 720
don't just drop Channels on the floor if registration fails #413
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Tests/NIOTests/ChannelTests.swift
Outdated
| typealias OutboundIn = Never | ||
|
|
||
| func register(ctx: ChannelHandlerContext, promise: EventLoopPromise<Void>?) { | ||
| promise?.fail(error: RegistrationFailedError.error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@weissi maybe use ! as it should never be nil.
| } | ||
| .bind(host: "localhost", port: 0).wait() | ||
| XCTFail("shouldn't be reached") | ||
| XCTAssertNoThrow(try serverChannel.close().wait()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this one as it should never be reached anyway ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added it because if it fails, not closing it leads to a crash (assert) and then hides the actual bug. I’d leave it in but am also happy to take out.
You know, xctest doesn’t stop on failed assert...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah right... Ignore me then (or maybe add a comment) :)
|
@swift-nio-bot test this please |
|
19:16:20 Test Case 'ChannelTests.testFailedRegistrationOfAcceptedSocket' started at 2018-05-17 19:16:20.374 |
Tests/NIOTests/ChannelTests.swift
Outdated
| .connect(to: serverChannel.localAddress!) | ||
| .wait() | ||
| defer { | ||
| XCTAssertNoThrow(try clientChannel.close().wait()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a race in this close, racing with the close in the accepted server socket. Better to just wait for the closeFuture on this channel, which has the nice side effect of confirming that the channel actually did die.
| group: childEventLoopGroup, | ||
| protocolFamily: address.protocolFamily) | ||
| } | ||
| return bind0(makeServerChannel: makeChannel) { (eventGroup, serverChannel) in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should bind0 do this error handling? There are a few other paths through this bootstrap that didn't get changed here but that still do registrations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done now, thanks
0fbcdc4 to
f52da00
Compare
f52da00 to
71cdf87
Compare
|
@swift-nio-bot test this please |
|
@normanmaurer / @Lukasa updated this PR |
|
This has regressed allocations on 4.1, it seems. |
|
@Lukasa sadly that is expected as I added extra future related allocations. But should only be per connection not per request. Will change the docket setup in this PR tomorrow :( Wow, looks like 16 allocations more per connection pair. That’s a lot. Will look into that tomo. Btw, we only check allocations on 4.1 (and not 4.0) hence only those are failing |
Motivation: If registration of a Channel fails we need to close that Channel. Previously we'd just drop it on the floor which triggers an assertion that an open channel got leaked. Modifications: In cases where the Channel registration fails, we need to close that channel. Result: - No crashes if registration fails. - fixes apple#417
71cdf87 to
f3e038c
Compare
Lukasa
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, ship it.
Motivation:
If registration of a Channel fails we need to close that Channel.
Previously we'd just drop it on the floor which triggers an assertion
that an open channel got leaked.
Modifications:
In cases where the Channel registration fails, we need to close that
channel.
Result:
No crashes if registration fails.