Skip to content

Commit

Permalink
Fixes #11527 - Reduce ByteBuffer churning in HttpOutput.
Browse files Browse the repository at this point in the history
Now releasing the buffer back into the pool.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
  • Loading branch information
sbordet committed Mar 18, 2024
1 parent d39899f commit fe94c9f
Showing 1 changed file with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ private void onWriteComplete(boolean last, Throwable failure)
_state = State.CLOSED;
closedCallback = _closedCallback;
_closedCallback = null;
releaseBuffer(failure);
releaseBuffer();
wake = updateApiState(failure);
}
else if (_state == State.CLOSE)
Expand Down Expand Up @@ -508,7 +508,7 @@ public void completed(Throwable failure)
try (AutoLock l = _channelState.lock())
{
_state = State.CLOSED;
releaseBuffer(failure);
releaseBuffer();
}
}

Expand Down Expand Up @@ -648,15 +648,12 @@ private ByteBuffer acquireBuffer()
return _aggregate;
}

private void releaseBuffer(Throwable failure)
private void releaseBuffer()
{
if (_aggregate != null)
{
ByteBufferPool bufferPool = _channel.getConnector().getByteBufferPool();
if (failure == null)
bufferPool.release(_aggregate);
else
bufferPool.remove(_aggregate);
bufferPool.release(_aggregate);
_aggregate = null;
}
}
Expand Down Expand Up @@ -1403,7 +1400,7 @@ public void recycle()
_commitSize = config.getOutputAggregationSize();
if (_commitSize > _bufferSize)
_commitSize = _bufferSize;
releaseBuffer(null);
releaseBuffer();
_written = 0;
_writeListener = null;
_onError = null;
Expand Down

0 comments on commit fe94c9f

Please sign in to comment.