-
Notifications
You must be signed in to change notification settings - Fork 123
Fix leaked TLS handshake promise #180
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
Fix leaked TLS handshake promise #180
Conversation
@@ -383,32 +383,33 @@ final class ConnectionPool { | |||
} | |||
|
|||
return channel.flatMap { channel -> EventLoopFuture<ConnectionPool.Connection> in | |||
channel.pipeline.addSSLHandlerIfNeeded(for: self.key, tlsConfiguration: self.configuration.tlsConfiguration, handshakePromise: handshakePromise).flatMap { | |||
channel.pipeline.addSSLHandlerIfNeeded(for: self.key, tlsConfiguration: self.configuration.tlsConfiguration, handshakePromise: handshakePromise) |
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.
The promise and returned future were redundant IMO so this only makes use of handshakePromise
now
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. Nice patch!
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.
Thank you! This looks really good, small suggestion for a better test
defer { | ||
XCTAssertNoThrow(try httpClient.syncShutdown(requiresCleanClose: true)) | ||
} | ||
XCTAssertThrowsError(try httpClient.get(url: "http://localhost/").wait()) { error 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.
this test isn't great. It relies on nothing being bound to port 80 on localhost
. Can I suggest a slightly different strategy: Let's bind a random port with a server socket, then immediately close it and then connect that port instead and we have pretty high confidence that this port won't be bound by something else
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 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.
Oops actually I don't think it does, I must still close it because the connection is still accepted it seems
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 Latest push should be ok 🙂
motivation: TLS handshake promise was leaked in some cases of failure (see #179) changes: - Avoid leaking promise - Clearer completion flow for related futures - Add testAvoidLeakingTLSHandshakeCompletionPromise test
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.
looks great, thanks!
motivation:
TLS handshake promise was leaked in some cases of failure (fixes #179)
changes: