Skip to content

Commit

Permalink
fix over-releases and add comment
Browse files Browse the repository at this point in the history
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
  • Loading branch information
lorban committed Jan 24, 2024
1 parent a617f3d commit 2b800a9
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,12 @@ public void onFillable()
LOG.debug("Read {} bytes from {} {}", read, getEndPoint(), this);
if (read > 0)
{
// The networkBuffer cannot be released immediately after parse()
// even if the buffer has been fully consumed because releaseInputBuffer()
// must be called as the last release for it to be able to null out the
// networkBuffer field exactly when the latter isn't used anymore.
if (parse(networkBuffer.getByteBuffer()))
{
if (!networkBuffer.hasRemaining())
releaseInputBuffer();
break;
}
}
else if (read == 0)
{
Expand Down Expand Up @@ -230,12 +230,12 @@ void parseAndFill()
// See also HttpConnection.parseAndFillForContent().
while (stream != null)
{
// The networkBuffer cannot be released immediately after parse()
// even if the buffer has been fully consumed because releaseInputBuffer()
// must be called as the last release for it to be able to null out the
// networkBuffer field exactly when the latter isn't used anymore.
if (parse(networkBuffer.getByteBuffer()))
{
if (!networkBuffer.hasRemaining())
releaseInputBuffer();
break;
}

// Check if the request was completed by the parsing.
if (stream == null || fillInputBuffer() <= 0)
Expand Down

0 comments on commit 2b800a9

Please sign in to comment.