mirror of
https://github.com/apple/swift-nio-http2
synced 2026-11-30 05:28:45 +00:00
Drop buffered outbound frames when closing. (#135)
Motivation:
While having outbound buffers is necessary, it's pretty important to
clear then when the connection is closed, or the promise will get
leaked. In this case, leaking the promise is usually pretty dang bad,
and tends to cause awkward things like crashes.
Modifications:
- Added hooks to invalidate the CompoundOutboundBuffer.
- Called those hooks in handlerRemoved, where there is no reentrancy
risk.
Result:
Less risk of runtime crash.
This commit is contained in:
1 parent
dad9eee427
commit
419cd4eece
8 files changed
+107
No files matched your search
@@ -112,6 +112,11 @@ public final class NIOHTTP2Handler: ChannelDuplexHandler {
|
||||
}
|
||||
}
|
||||
|
||||
public func handlerRemoved(context: ChannelHandlerContext) {
|
||||
// Any frames we're buffering need to be dropped.
|
||||
self.outboundBuffer.invalidateBuffer()
|
||||
}
|
||||
|
||||
public func channelActive(context: ChannelHandlerContext) {
|
||||
self.writeAndFlushPreamble(context: context)
|
||||
context.fireChannelActive()
|
||||
|
||||
Reference in new issue
Block a user