Skip to content

Commit

Permalink
#12776 do not repool the buffer when releasing upon failure as the H2…
Browse files Browse the repository at this point in the history
… flusher might still reference it

Signed-off-by: Ludovic Orban <[email protected]>
  • Loading branch information
lorban committed Feb 10, 2025
1 parent c9200a5 commit 8786eb0
Showing 1 changed file with 8 additions and 5 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();
releaseBuffer(failure);
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();
releaseBuffer(failure);
}
}

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

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

0 comments on commit 8786eb0

Please sign in to comment.