Skip to content

Zero length data frames should apply flow control #3348

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
wants to merge 1 commit into from
Closed

Zero length data frames should apply flow control #3348

wants to merge 1 commit into from

Conversation

codefromthecrypt
Copy link

Eventhough zero-length data frames don't have a WINDOW_UPDATE side-effect, flow-control logic should be applied. This allows for proper end-of-stream handling.

@netkins
Copy link

netkins commented Jan 22, 2015

AUTOMATED MESSAGE for ADMINS:
Please verify and accept the pull request.
To accept, say @netkins accept
To build again, say @netkins build
To whitelist the author, say @netkins whitelist

@@ -252,7 +252,7 @@ public int onDataRead(final ChannelHandlerContext ctx, int streamId, ByteBuf dat
Http2LocalFlowController flowController = flowController();
try {
// If we should apply flow control, do so now.
if (shouldApplyFlowControl) {
if (shouldApplyFlowControl && bytesToReturn > 0) {
flowController.receiveFlowControlledFrame(ctx, stream, data, padding, endOfStream);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

entering this when bytesToReturn == 0 leads to assertion errors

@normanmaurer
Copy link
Member

@netkins accept

@normanmaurer
Copy link
Member

@Scottmitch @nmittler please check

@@ -252,7 +252,7 @@ public int onDataRead(final ChannelHandlerContext ctx, int streamId, ByteBuf dat
Http2LocalFlowController flowController = flowController();
try {
// If we should apply flow control, do so now.
if (shouldApplyFlowControl) {
if (shouldApplyFlowControl && bytesToReturn > 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should fix the assertion statement instead to accept 0 (i.e. assert dataLength >= 0). Not because 0 is expected to impact flow control but the endOfStream still needs to be processed. If more issues fall out from this we should investigate those too.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, I think this statement was correct before. We should always be applying flow control if shouldApplyFlowControl is true.

Which assertion was failing? In the new test?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which assertion was failing? In the new test?

I am guessing @adriancole was referring to this assertion statement. Please correct me if I'm wrong (or if there are other asserts that are also failing).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah right, I think that assert should just make sure the value passed in isn't negative (i.e. >=).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Scottmitch sorry, I read your original comment via e-mail so I didn't realize you had already provided the link ;)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, I read your original comment via e-mail so I didn't realize you had already provided the link ;)

No problem. Just to confuse things even more...I sometimes edit my comments to clarify/correct after the emails go out anyhow :). I always double check comments I get through email on github.

@Scottmitch Scottmitch added this to the 5.0.0.Alpha2 milestone Jan 22, 2015
@Scottmitch Scottmitch self-assigned this Jan 22, 2015
@Scottmitch
Copy link
Member

@adriancole - Good catch and thanks for the patch! I have left a few comments, let me know what you think.

@nmittler
Copy link
Member

@adriancole good catch! :)

@codefromthecrypt codefromthecrypt changed the title Zero length data frames should not incur flow control Zero length data frames should apply flow control Jan 23, 2015
@codefromthecrypt
Copy link
Author

Thanks'all. I've updated the code and the PR description.

@Scottmitch
Copy link
Member

@adriancole could you please update your commit comment http://netty.io/wiki/writing-a-commit-message.html?

Motivation:
A downstream consumer of Netty failed as emitting zero-length http2 data frames in a unit test resulted in assertion errors in Http2LocalFlowController. Since zero-length frames are valid, an assertion that http2 data frame length must be positive is invalid.

Modifications:

Assertions of data length in Http2LocalFlowController now permit zero.

Result:

Those running netty with assertions on can now emit zero length http2 data frames.
@codefromthecrypt
Copy link
Author

big commit message applied :)

@normanmaurer
Copy link
Member

@adriancole thanks buddy! Cherry-picked into master. @Scottmitch we need to remember to cherry-pick this one once http2 is backported into 4.1

@Scottmitch
Copy link
Member

@normanmaurer - Yes. Will do.

@Scottmitch
Copy link
Member

cherry picked into 4.1 (c6bfc92)

@codefromthecrypt
Copy link
Author

thanks for the review and pickings!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants