Cosmetics.
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
This commit is contained in:
parent
5ee856c0c1
commit
1e439535c1
|
@ -136,7 +136,8 @@ public class HTTP2Connection extends AbstractConnection implements WriteFlusher.
|
||||||
}
|
}
|
||||||
catch (IOException x)
|
catch (IOException x)
|
||||||
{
|
{
|
||||||
LOG.debug("Could not read from " + endPoint, x);
|
if (LOG.isDebugEnabled())
|
||||||
|
LOG.debug("Could not read from " + endPoint, x);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -210,15 +211,15 @@ public class HTTP2Connection extends AbstractConnection implements WriteFlusher.
|
||||||
protected class HTTP2Producer implements ExecutionStrategy.Producer
|
protected class HTTP2Producer implements ExecutionStrategy.Producer
|
||||||
{
|
{
|
||||||
private final Callback fillableCallback = new FillableCallback();
|
private final Callback fillableCallback = new FillableCallback();
|
||||||
private NetworkBuffer buffer;
|
private NetworkBuffer networkBuffer;
|
||||||
private boolean shutdown;
|
private boolean shutdown;
|
||||||
private boolean failed;
|
private boolean failed;
|
||||||
|
|
||||||
private void setInputBuffer(ByteBuffer byteBuffer)
|
private void setInputBuffer(ByteBuffer byteBuffer)
|
||||||
{
|
{
|
||||||
if (buffer == null)
|
if (networkBuffer == null)
|
||||||
buffer = acquireNetworkBuffer();
|
networkBuffer = acquireNetworkBuffer();
|
||||||
buffer.put(byteBuffer);
|
networkBuffer.put(byteBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -233,27 +234,29 @@ public class HTTP2Connection extends AbstractConnection implements WriteFlusher.
|
||||||
if (isFillInterested() || shutdown || failed)
|
if (isFillInterested() || shutdown || failed)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if (buffer == null)
|
if (networkBuffer == null)
|
||||||
buffer = acquireNetworkBuffer();
|
networkBuffer = acquireNetworkBuffer();
|
||||||
boolean parse = buffer.hasRemaining();
|
|
||||||
|
boolean parse = networkBuffer.hasRemaining();
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
if (parse)
|
if (parse)
|
||||||
{
|
{
|
||||||
buffer.retain();
|
|
||||||
boolean released;
|
boolean released;
|
||||||
|
networkBuffer.retain();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
while (buffer.hasRemaining())
|
while (networkBuffer.hasRemaining())
|
||||||
{
|
{
|
||||||
parser.parse(buffer.buffer);
|
parser.parse(networkBuffer.buffer);
|
||||||
if (failed)
|
if (failed)
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
released = buffer.release();
|
released = networkBuffer.release();
|
||||||
if (failed && released)
|
if (failed && released)
|
||||||
releaseNetworkBuffer();
|
releaseNetworkBuffer();
|
||||||
}
|
}
|
||||||
|
@ -266,41 +269,41 @@ public class HTTP2Connection extends AbstractConnection implements WriteFlusher.
|
||||||
if (released)
|
if (released)
|
||||||
releaseNetworkBuffer();
|
releaseNetworkBuffer();
|
||||||
else
|
else
|
||||||
buffer = null;
|
networkBuffer = null;
|
||||||
return task;
|
return task;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!released)
|
if (!released)
|
||||||
buffer = acquireNetworkBuffer();
|
networkBuffer = acquireNetworkBuffer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Here we know that this.buffer is not retained:
|
// Here we know that this.buffer is not retained:
|
||||||
// either it has been released, or it's a new one.
|
// either it has been released, or it's a new one.
|
||||||
|
|
||||||
int filled = fill(getEndPoint(), buffer.buffer);
|
int filled = fill(getEndPoint(), networkBuffer.buffer);
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
LOG.debug("Filled {} bytes in {}", filled, buffer);
|
LOG.debug("Filled {} bytes in {}", filled, networkBuffer);
|
||||||
|
|
||||||
if (filled == 0)
|
if (filled > 0)
|
||||||
|
{
|
||||||
|
bytesIn.addAndGet(filled);
|
||||||
|
parse = true;
|
||||||
|
}
|
||||||
|
else if (filled == 0)
|
||||||
{
|
{
|
||||||
releaseNetworkBuffer();
|
releaseNetworkBuffer();
|
||||||
getEndPoint().fillInterested(fillableCallback);
|
getEndPoint().fillInterested(fillableCallback);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
else if (filled < 0)
|
else
|
||||||
{
|
{
|
||||||
releaseNetworkBuffer();
|
releaseNetworkBuffer();
|
||||||
shutdown = true;
|
shutdown = true;
|
||||||
session.onShutdown();
|
session.onShutdown();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
bytesIn.addAndGet(filled);
|
|
||||||
parse = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -315,9 +318,9 @@ public class HTTP2Connection extends AbstractConnection implements WriteFlusher.
|
||||||
private void releaseNetworkBuffer()
|
private void releaseNetworkBuffer()
|
||||||
{
|
{
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
LOG.debug("Released {}", buffer);
|
LOG.debug("Released {}", networkBuffer);
|
||||||
buffer.recycle();
|
networkBuffer.recycle();
|
||||||
buffer = null;
|
networkBuffer = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -358,9 +361,9 @@ public class HTTP2Connection extends AbstractConnection implements WriteFlusher.
|
||||||
@Override
|
@Override
|
||||||
public void onData(DataFrame frame)
|
public void onData(DataFrame frame)
|
||||||
{
|
{
|
||||||
NetworkBuffer buffer = producer.buffer;
|
NetworkBuffer networkBuffer = producer.networkBuffer;
|
||||||
buffer.retain();
|
networkBuffer.retain();
|
||||||
Callback callback = buffer;
|
Callback callback = networkBuffer;
|
||||||
session.onData(frame, callback);
|
session.onData(frame, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue