handle slow arriving input

This commit is contained in:
Greg Wilkins 2015-02-05 14:27:05 +11:00
parent 1576c68a52
commit d08fced010
1 changed files with 21 additions and 8 deletions

View File

@ -364,8 +364,11 @@ public abstract class HttpInput<T> extends ServletInputStream implements Runnabl
@Override @Override
public void setReadListener(ReadListener readListener) public void setReadListener(ReadListener readListener)
{
try
{ {
readListener = Objects.requireNonNull(readListener); readListener = Objects.requireNonNull(readListener);
boolean content;
synchronized (lock()) synchronized (lock())
{ {
if (_contentState != STREAM) if (_contentState != STREAM)
@ -373,8 +376,18 @@ public abstract class HttpInput<T> extends ServletInputStream implements Runnabl
_contentState = ASYNC; _contentState = ASYNC;
_listener = readListener; _listener = readListener;
_notReady = true; _notReady = true;
content = getNextContent()!=null;
} }
if (content)
_channelState.onReadPossible(); _channelState.onReadPossible();
else
unready();
}
catch(IOException e)
{
throw new RuntimeIOException(e);
}
} }
public void failed(Throwable x) public void failed(Throwable x)