406617 Spin in Request.recylce
removed loop from read, so only a single attempt a blocking for content.
This commit is contained in:
parent
92a39fcb08
commit
22b0098be7
|
@ -561,6 +561,7 @@ public class HttpConnection extends AbstractConnection implements Runnable, Http
|
|||
if (getEndPoint().isInputShutdown())
|
||||
{
|
||||
_parser.shutdownInput();
|
||||
shutdown();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -96,21 +96,26 @@ public abstract class HttpInput<T> extends ServletInputStream
|
|||
T item = null;
|
||||
synchronized (lock())
|
||||
{
|
||||
while (item == null)
|
||||
{
|
||||
// Get the current head of the input Q
|
||||
item = _inputQ.peekUnsafe();
|
||||
|
||||
// Skip empty items at the head of the queue
|
||||
while (item != null && remaining(item) == 0)
|
||||
{
|
||||
_inputQ.pollUnsafe();
|
||||
onContentConsumed(item);
|
||||
LOG.debug("{} consumed {}", this, item);
|
||||
item = _inputQ.peekUnsafe();
|
||||
|
||||
// If that was the last item then notify
|
||||
if (item==null)
|
||||
onAllContentConsumed();
|
||||
}
|
||||
|
||||
// If we have no item
|
||||
if (item == null)
|
||||
{
|
||||
onAllContentConsumed();
|
||||
|
||||
// Was it unexpectedly EOF'd?
|
||||
if (isEarlyEOF())
|
||||
throw new EofException();
|
||||
|
||||
|
@ -121,7 +126,23 @@ public abstract class HttpInput<T> extends ServletInputStream
|
|||
return -1;
|
||||
}
|
||||
|
||||
// OK then block for some more content
|
||||
blockForContent();
|
||||
|
||||
// If still not content, we must be closed
|
||||
item = _inputQ.peekUnsafe();
|
||||
if (item==null)
|
||||
{
|
||||
if (isEarlyEOF())
|
||||
throw new EofException();
|
||||
|
||||
// blockForContent will only return with no
|
||||
// content if it is closed.
|
||||
if (!isShutdown())
|
||||
LOG.warn("unexpected !EOF state");
|
||||
|
||||
onEOF();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue