Skip to content

Commit

Permalink
Fixes #5691 - HttpInput may skip setting fill interest.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
sbordet committed Nov 20, 2020
1 parent 8edb5cf commit 4654335
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -222,18 +222,33 @@ public boolean isReady()
if (content == null)
{
_httpChannel.getState().onReadUnready();
if (_httpChannel.needContent())
while (true)
{
content = nextTransformedContent();
if (LOG.isDebugEnabled())
LOG.debug("isReady got transformed content after needContent retry {}", content);
if (content != null)
_httpChannel.getState().onContentAdded();
}
else
{
if (LOG.isDebugEnabled())
LOG.debug("isReady has no transformed content after needContent");
if (_httpChannel.needContent())
{
content = nextTransformedContent();
if (LOG.isDebugEnabled())
LOG.debug("isReady got transformed content after needContent retry {} {}", content, this);
if (content != null)
{
_httpChannel.getState().onContentAdded();
break;
}
else
{
// We could have read some rawContent but not enough to generate
// transformed content, so we need to call needContent() again
// to tell the channel that more content is needed.
if (LOG.isDebugEnabled())
LOG.debug("isReady could not transform content after needContent retry {}", this);
}
}
else
{
if (LOG.isDebugEnabled())
LOG.debug("isReady false needContent retry {}", this);
break;
}
}
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,13 @@ public int available()
@Override
public void run()
{
// Call isReady() to make sure that if not ready we register for fill interest.
if (!_contentProducer.isReady())
{
if (LOG.isDebugEnabled())
LOG.debug("running but not ready {}", this);
return;
}
Content content = _contentProducer.nextContent();
if (LOG.isDebugEnabled())
LOG.debug("running on content {} {}", content, this);
Expand Down

0 comments on commit 4654335

Please sign in to comment.