Skip to content
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

Fixes #8405 - onAllDataRead() is called twice under h2 if the stream … #10174

Merged
merged 3 commits into from Jul 31, 2023

Conversation

sbordet
Copy link
Contributor

@sbordet sbordet commented Jul 30, 2023

…times out

Per Servlet semantic, HTTP/2 stream timeout should be ignored.

The code was trying to fail the read via _contentDemander.onTimeout(), but then it was still calling onContentProducible(), which was returning true because the state of the read was IDLE (all the request content was read) and the request was suspended.

Now the code checks if the read was really failed; if it is not, then onContentProducible() is not called and so the idle timeout is ignored.

…times out

Per Servlet semantic, HTTP/2 stream timeout should be ignored.

The code was trying to fail the read via `_contentDemander.onTimeout()`, but
then it was still calling `onContentProducible()`, which was returning `true`
because the state of the read was IDLE (all the request content was read) and
the request was suspended.

Now the code checks if the read was really failed; if it is not, then
`onContentProducible()` is not called and so the idle timeout is ignored.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Copy link
Contributor

@gregw gregw left a comment

Choose a reason for hiding this comment

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

I have a middle about the code clarity and the branch is out of date. But other than that, looks good. Update the branch and consider the niggle and I'll re review

boolean needed = getRequest().getHttpInput().onContentProducible();
boolean readFailed = _contentDemander.onTimeout(failure);
boolean needed = false;
if (readFailed)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think a simple && would be clear here.
Needed = on timeout && contentProducable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@gregw I disagree that it would be clearer to lose the variable names and rely on && short circuiting.
I have renamed needed to handle.

Copy link
Contributor

Choose a reason for hiding this comment

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

Nah! You can keep the variable name but get rid of the manual short-circuit:

boolean = readFailed && getRequest().getHttpInput().onContentProducible();

lorban
lorban previously approved these changes Jul 31, 2023
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
@sbordet sbordet merged commit 87c24e7 into jetty-10.0.x Jul 31, 2023
2 of 3 checks passed
@sbordet sbordet deleted the fix/jetty-10-8405-onAllDataRead-called-twice branch July 31, 2023 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants