-
Notifications
You must be signed in to change notification settings - Fork 125
Fix HTTP2StreamChannel leak #657
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,7 +77,7 @@ final class HTTP2Connection { | |
|
||
/// We use this channel set to remember, which open streams we need to inform that | ||
/// we want to close the connection. The channels shall than cancel their currently running | ||
/// request. | ||
/// request. This property must only be accessed from the connections `EventLoop`. | ||
private var openStreams = Set<ChannelBox>() | ||
let id: HTTPConnectionPool.Connection.ID | ||
let decompression: HTTPClient.Decompression | ||
|
@@ -241,7 +241,7 @@ final class HTTP2Connection { | |
// before. | ||
let box = ChannelBox(channel) | ||
self.openStreams.insert(box) | ||
self.channel.closeFuture.whenComplete { _ in | ||
channel.closeFuture.whenComplete { _ in | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the actual bug fix. However I have no idea how to test it! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have run into this just today. If we send a too large header and the server sends a go away frame the child channel is closed but the parent channel not. This might be a good way to test this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can try to test this by triggering the shutdown event and finding which channels get sent this user event. So long as we can hook the parent channel we should observe that it doesn't see it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The question is: How do I get access to the stream/child channel? All the ideas I had so far a quite locked down. Of course I can add an internal function that gives me the currently active channels.
wdyt? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think adding a testing function is fine. You can guard it behind an SPI, which is probably sufficient. |
||
self.openStreams.remove(box) | ||
} | ||
|
||
|
@@ -287,6 +287,11 @@ final class HTTP2Connection { | |
preconditionFailure("invalid state \(self.state)") | ||
} | ||
} | ||
|
||
func __forTesting_getStreamChannels() -> [Channel] { | ||
self.channel.eventLoop.preconditionInEventLoop() | ||
return self.openStreams.map { $0.channel } | ||
} | ||
} | ||
|
||
extension HTTP2Connection: HTTP2IdleHandlerDelegate { | ||
|
Uh oh!
There was an error while loading. Please reload this page.