Skip to content

Commit

Permalink
Fixed ConnectHandler ICB usage
Browse files Browse the repository at this point in the history
See #11932
  • Loading branch information
gregw committed Jun 19, 2024
1 parent 5cb8f8b commit 961393e
Showing 1 changed file with 19 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,11 @@ private class ProxyIteratingCallback extends IteratingCallback
@Override
protected Action process()
{
buffer = bufferPool.acquire(getInputBufferSize(), true);
if (buffer == null)
buffer = bufferPool.acquire(getInputBufferSize(), true);
else
buffer.clear();

try
{
ByteBuffer byteBuffer = buffer.getByteBuffer();
Expand All @@ -736,18 +740,18 @@ protected Action process()
write(connection.getEndPoint(), byteBuffer, this);
return Action.SCHEDULED;
}
else if (filled == 0)

buffer.release();
buffer = null;

if (filled == 0)
{
buffer.release();
fillInterested();
return Action.IDLE;
}
else
{
buffer.release();
connection.getEndPoint().shutdownOutput();
return Action.SUCCEEDED;
}

connection.getEndPoint().shutdownOutput();
return Action.SUCCEEDED;
}
catch (IOException x)
{
Expand All @@ -760,26 +764,19 @@ else if (filled == 0)
}

@Override
public void succeeded()
{
if (LOG.isDebugEnabled())
LOG.debug("Wrote {} bytes {}", filled, TunnelConnection.this);
buffer.release();
super.succeeded();
}

@Override
protected void onCompleteSuccess()
protected void onAborted(Throwable cause)
{
disconnect(cause);
}

@Override
protected void onCompleteFailure(Throwable x)
protected void onCompleteFailure(Throwable cause)
{
if (LOG.isDebugEnabled())
LOG.debug("Failed to write {} bytes {}", filled, TunnelConnection.this, x);
LOG.debug("Failed to write {} bytes {}", filled, TunnelConnection.this, cause);
buffer.release();
disconnect(x);
buffer = null;
disconnect(cause);
}

private void disconnect(Throwable x)
Expand Down

0 comments on commit 961393e

Please sign in to comment.