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

HttpInput may skip setting fill interest #5692

Merged
merged 4 commits into from
Nov 23, 2020

Conversation

sbordet
Copy link
Contributor

@sbordet sbordet commented Nov 20, 2020

@gregw @lorban the first commit is logging improvements, the second commit is the actual fix.

Code cleanups and logging improvements.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
HttpInput.run() now uses contentProvider.isReady() to ensure that
if there is no content, the fill interest is set.

AsyncContentProvider.isReady() is now looping if there is content
but it cannot be transformed (e.g. too few gzipped bytes).

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
@sbordet sbordet requested review from gregw and lorban November 20, 2020 15:53
@sbordet sbordet linked an issue Nov 20, 2020 that may be closed by this pull request
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 think one method could be written in a more simple form.... but that made me question if we really need to call onContentAdded in the case we don't call onReadUnready from isReady(). @lorban thoughts?

@@ -222,24 +222,39 @@ public boolean isReady()
if (content == null)
{
_httpChannel.getState().onReadUnready();
if (_httpChannel.needContent())
while (true)
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 this method is correct, but I think it would read better as:

public boolean isReady()
{
    HttpInput.Content content = nextTransformedContent();
    if (content != null)
    {
        // TODO do we really need to call onContentAdded in this case??? I don't think so as we have not called onReadUnready
        return true;
    }
            
   _httpChannel.getState().onReadUnready();
    while (_httpChannel.needContent())
    {
        HttpInput.Content content = nextTransformedContent();
        if (content != null)
        {
            _httpChannel.getState().onContentAdded();
            return true;
        }
        _httpChannel.getState().onReadUnready();
    }

    return false;
}

Copy link
Contributor

@lorban lorban Nov 23, 2020

Choose a reason for hiding this comment

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

@gregw Regarding your TODO, yes you must call onContentAdded in this case. Imagine a servlet calling isReady twice. The first time false is returned but the 2nd time true is returned. If you do not call onContentAdded to switch the state to READY, it'll be stuck at UNREADY which will cause havoc.

Oh, and I also added in the javadoc of ContentProducer.isReady that After this call, state can be either of UNREADY or READY as the state cannot be left IDLE after isReady is called.

Copy link
Contributor

Choose a reason for hiding this comment

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

@lorban But if isReady() has returned false, then regardless of it being called another time there is a scheduling action that will take place behind the scenes to make sure onDataAvailable is called when data becomes available. Surely it is that action that will call onContentAdded. Can you write a test case to demonstrate why this call is needed?

Copy link
Contributor

Choose a reason for hiding this comment

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

I've opened #5704 to track this.

Updates after review.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
@sbordet sbordet requested a review from gregw November 21, 2020 15:40
Copy link
Contributor

@lorban lorban left a comment

Choose a reason for hiding this comment

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

LGTM

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.

LGTM other than the comments that would be good to get @lorban to confirm

@sbordet sbordet merged commit d9b9235 into jetty-10.0.x Nov 23, 2020
@sbordet sbordet deleted the jetty-10.0.x-5691-httpinput_skip_fill_interest branch November 23, 2020 12:25
@joakime joakime changed the title Jetty 10.0.x 5691 httpinput skip fill interest HttpInput may skip setting fill interest Dec 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HttpInput may skip setting fill interest
3 participants