Fix #5605 Unblock non container Threads

Simplification. Always abort on any pending read or write in completion.
This commit is contained in:
gregw 2021-02-04 09:58:24 +01:00
parent e9315fe51f
commit 7235e492c8
2 changed files with 25 additions and 29 deletions

View File

@ -376,39 +376,40 @@ public class HttpConnection extends AbstractConnection implements Runnable, Http
@Override
public void onCompleted()
{
// If we are fill interested, then a read is pending and we must abort
if (isFillInterested())
{
LOG.warn("Pending read in onCompleted {} {}", this, getEndPoint());
abort(new IllegalStateException());
}
// Handle connection upgrades
if (_channel.getResponse().getStatus() == HttpStatus.SWITCHING_PROTOCOLS_101)
{
Connection connection = (Connection)_channel.getRequest().getAttribute(UPGRADE_CONNECTION_ATTRIBUTE);
if (connection != null)
{
if (isFillInterested())
abort(new IllegalStateException());
if (LOG.isDebugEnabled())
LOG.debug("Upgrade from {} to {}", this, connection);
_channel.getState().upgrade();
getEndPoint().upgrade(connection);
_channel.recycle();
_parser.reset();
_generator.reset();
if (_contentBufferReferences.get() == 0)
releaseRequestBuffer();
else
{
if (LOG.isDebugEnabled())
LOG.debug("Upgrade from {} to {}", this, connection);
_channel.getState().upgrade();
getEndPoint().upgrade(connection);
_channel.recycle();
_parser.reset();
_generator.reset();
if (_contentBufferReferences.get() == 0)
releaseRequestBuffer();
else
{
LOG.warn("{} lingering content references?!?!", this);
_requestBuffer = null; // Not returned to pool!
_contentBufferReferences.set(0);
}
LOG.warn("{} lingering content references?!?!", this);
_requestBuffer = null; // Not returned to pool!
_contentBufferReferences.set(0);
}
return;
}
}
// Drive to EOF, EarlyEOF or Error
boolean complete = _input.consumeAll();
if (isFillInterested())
abort(new IllegalStateException());
// Finish consuming the request
// If we are still expecting

View File

@ -450,20 +450,15 @@ public class HttpOutput extends ServletOutputStream implements Runnable
break;
case BLOCKED:
// An operation is in progress, so we soft close now
_softClose = true;
// then cancel the operation
CancellationException cancelled = new CancellationException();
if (_writeBlocker.fail(cancelled))
_channel.abort(cancelled);
// then trigger a close from onWriteComplete
_state = State.CLOSE;
break;
case UNREADY:
case PENDING:
LOG.warn("Pending write onComplated {} {}", this, _channel);
// An operation is in progress, so we soft close now
_softClose = true;
// then cancel the operation and abort the channel
CancellationException cancelled = new CancellationException();
_writeBlocker.fail(cancelled);
_channel.abort(cancelled);
// then trigger a close from onWriteComplete
_state = State.CLOSE;
break;