-
Notifications
You must be signed in to change notification settings - Fork 80
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
Avoid emitting WINDOW_UPDATE frames when receiving stream closed #233
Conversation
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 think passing this as a flag doesn't quite work: if for any reason we get a re-entrant call to read0
we'll lose track of the state.
Perhaps this should be state on the InboundWindowManager
: we can flip a bit there to say that there is no point sending window update frames anymore. This can then be done in a bunch of places, including when we receive END_STREAM
.
007171c
to
fc90c57
Compare
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.
Broadly looks good, a quick note on the implementation style.
@@ -67,7 +71,16 @@ struct InboundWindowManager { | |||
return self.calculateWindowIncrement(windowSize: lastWindowSize + self.bufferedBytes) | |||
} | |||
|
|||
mutating func close() { |
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 don't think the indirection is needed; lets just have closed
be an internal property on the window manager and set it directly.
fc90c57
to
754d458
Compare
Motivation: In some cases it's possible for a stream to emit a WINDOW_UPDATE frame after receiving close from the network. This is unfortunate because in the eyes of the `NIOHTTP2Handler` the stream no longer exists which results in a connection-level error. Modifications: - Add a `close()` to the `InboundWindowManager`, no new frame sizes will be produced if close has been called - Use the above functionality when the stream is closing and when we have seen end stream. Result: WINDOW_UPDATE frames are no longer emitted from the stream as a result of delivering pending reads while closing.
754d458
to
643b923
Compare
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.
Fantastic, this looks really good.
Motivation:
In some cases it's possible for a stream to emit a WINDOW_UPDATE frame
after receiving close from the network. This is unfortunate because in
the eyes of the
NIOHTTP2Handler
the stream no longer exists whichresults in a connection-level error.
Modifications:
deliverPendingReads
telling it whether it is allowedto emit a WINDOW_UPDATE frame
Result:
WINDOW_UPDATE frames are no longer emitted from the stream as a result
of delivering pending reads while closing.