Merged branch 'jetty-9.4.x' into 'jetty-10.0.x'.

This commit is contained in:
Simone Bordet 2019-05-20 11:04:24 +02:00
commit a2465234c6
2 changed files with 27 additions and 15 deletions

View File

@ -51,6 +51,7 @@ public class HttpConnectionOverHTTP2 extends HttpConnection implements Sweeper.S
private final AtomicBoolean closed = new AtomicBoolean();
private final AtomicInteger sweeps = new AtomicInteger();
private final Session session;
private boolean recycleHttpChannels;
public HttpConnectionOverHTTP2(HttpDestination destination, Session session)
{
@ -63,6 +64,16 @@ public class HttpConnectionOverHTTP2 extends HttpConnection implements Sweeper.S
return session;
}
public boolean isRecycleHttpChannels()
{
return recycleHttpChannels;
}
public void setRecycleHttpChannels(boolean recycleHttpChannels)
{
this.recycleHttpChannels = recycleHttpChannels;
}
@Override
public SendFailure send(HttpExchange exchange)
{
@ -99,7 +110,7 @@ public class HttpConnectionOverHTTP2 extends HttpConnection implements Sweeper.S
// Recycle only non-failed channels.
if (channel.isFailed())
channel.destroy();
else
else if (isRecycleHttpChannels())
idleChannels.offer(channel);
}
else

View File

@ -213,21 +213,21 @@ public class HttpReceiverOverHTTP2 extends HttpReceiver implements Stream.Listen
@Override
protected Action process()
{
DataInfo dataInfo;
if (dataInfo != null)
{
dataInfo.callback.succeeded();
if (dataInfo.frame.isEndStream())
return Action.SUCCEEDED;
}
synchronized (this)
{
dataInfo = queue.poll();
}
if (dataInfo == null)
{
DataInfo prevDataInfo = this.dataInfo;
if (prevDataInfo != null && prevDataInfo.frame.isEndStream())
return Action.SUCCEEDED;
return Action.IDLE;
}
this.dataInfo = dataInfo;
ByteBuffer buffer = dataInfo.frame.getData();
if (buffer.hasRemaining())
responseContent(dataInfo.exchange, buffer, this);
@ -244,13 +244,6 @@ public class HttpReceiverOverHTTP2 extends HttpReceiver implements Stream.Listen
((Retainable)callback).retain();
}
@Override
public void succeeded()
{
dataInfo.callback.succeeded();
super.succeeded();
}
@Override
protected void onCompleteSuccess()
{
@ -263,6 +256,14 @@ public class HttpReceiverOverHTTP2 extends HttpReceiver implements Stream.Listen
dataInfo.callback.failed(failure);
responseFailure(failure);
}
@Override
public boolean reset()
{
queue.clear();
dataInfo = null;
return super.reset();
}
}
private static class DataInfo