Repository navigation
http2: use and support non-empty DATA frame with END_STREAM flag #33875
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
Closed
Closed
Changes from 1 commit
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
ca21bd1
http2: use and support non-empty DATA frame with END_STREAM flag
clshortfuse 1e35afd
remove whitespace
clshortfuse 30b1c06
Update node_http2.cc
clshortfuse 6f7c361
Update node_http2.cc
clshortfuse cbddeb6
Update node_http2.cc
clshortfuse acb5999
Update node_http2.cc
clshortfuse 85cf722
Update node_http2.cc
clshortfuse 7bae5a5
http2: add "receive paused" debug native line
clshortfuse 789cc1d
http2: remove empty DATA frame
clshortfuse 0c110d0
http2: update tests
clshortfuse 563a310
fix trailers flag detection
clshortfuse 327e9e8
fix tests
clshortfuse 58a3885
add test
clshortfuse 1778fc6
add state.shutdownWritableCalled
clshortfuse File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Update node_http2.cc
- Loading branch information
commit 30b1c06ae04c20b7da32ef6498c9f0de16d66664
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Hm – the
CHECK_LEabove this verifies that this is always the case, right?(Also, thanks for digging into this so deeply!)
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 spotted that too, but I wasn't sure. It's very possible this all comes from a single missing character!
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.
In reality, the whole conditional of
if (static_cast<size_t>(ret) < read_len) {is suspect. I don't think we need it, but I leaned on<=instead because it replicates theCHECK_LEline.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.
Hm … trying to think this through: If reading is paused but we still consumed the entire buffer, doesn’t that mean that we should clear the Buffer in the code below (i.e.
stream_buf_offset_ = 0;etc)?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.
We don't need the buffer, no. But we can't reset
stream_buf_offset_because we need to recallConsumeHTTP2Data()later:https://github.com/nodejs/node/blob/f46ca0fd29361215ac8a26cd6647dc45221eb9d7/src/node_http2.cc#L1457-1459
I was thinking
(stream_buf_offset_ > 0 || is_receive_paused()), but then it'll try to runConsumeHTTP2Data()every time you write something, even if the readable side is completed.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.
@clshortfuse So, just to make sure I understand this correctly: We should also call
nghttp2_session_mem_recv()even if no new data is available from the socket, and the previousnghttp2_session_mem_recv()call reported all data as read, if we entered pause state during that previous call?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.
Maybe we just shouldn’t pause in the first place if
NGHTTP2_FLAG_END_STREAMis set?Uh oh!
There was an error while loading. Please reload this page.
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.
@addaleax Yes. I tried to keep the comment to the point, since I'm known for blabbing 🙃, but the
nghttp2documentation states:https://nghttp2.org/documentation/types.html#c.nghttp2_on_data_chunk_recv_callback
Uh oh!
There was an error while loading. Please reload this page.
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.
Sorry, I missed this. That is entirely possible, but it would be less efficient memory-wise. The sooner we pause to send out an output chunk, the sooner it's released from RAM. Also, we have no way of knowing how many times the current data frame (though it has an
END_STREAMflag) will trigger a read callback. Frames can be upto 16MiB in size. So, hypothetically, ifnghttp2is sending us things in 1KB chunks, it could take 16,384 iterations before we send out whatever data we want. That could be any outbound frame type, includingPINGresponses.