Removed read buffers, since we do not need anymore reentrant parsing because we now call the application in a different thread.

This commit is contained in:
Simone Bordet 2012-02-28 17:02:23 +01:00
parent 50ead5c19c
commit 8392dab7b4
1 changed files with 11 additions and 22 deletions

View File

@ -39,7 +39,6 @@ public class SPDYAsyncConnection extends AbstractConnection implements AsyncConn
private static final Logger logger = LoggerFactory.getLogger(SPDYAsyncConnection.class); private static final Logger logger = LoggerFactory.getLogger(SPDYAsyncConnection.class);
private final Parser parser; private final Parser parser;
private volatile Session session; private volatile Session session;
private ByteBuffer readBuffer;
private ByteBuffer writeBuffer; private ByteBuffer writeBuffer;
private Handler<StandardSession.FrameBytes> writeHandler; private Handler<StandardSession.FrameBytes> writeHandler;
private StandardSession.FrameBytes writeContext; private StandardSession.FrameBytes writeContext;
@ -88,17 +87,10 @@ public class SPDYAsyncConnection extends AbstractConnection implements AsyncConn
public int fill() throws IOException public int fill() throws IOException
{ {
// In order to support reentrant parsing, we save the read buffer // TODO: use buffer pool
// so that reentrant calls can finish to consume the read buffer
// or eventually read more bytes and parse them.
int filled = 0;
if (readBuffer == null)
{
// TODO: use buffer pool ?
NIOBuffer jettyBuffer = new DirectNIOBuffer(4096); NIOBuffer jettyBuffer = new DirectNIOBuffer(4096);
AsyncEndPoint endPoint = getEndPoint(); AsyncEndPoint endPoint = getEndPoint();
filled = endPoint.fill(jettyBuffer); int filled = endPoint.fill(jettyBuffer);
logger.debug("Filled {} from {}", filled, endPoint); logger.debug("Filled {} from {}", filled, endPoint);
if (filled <= 0) if (filled <= 0)
return filled; return filled;
@ -106,10 +98,7 @@ public class SPDYAsyncConnection extends AbstractConnection implements AsyncConn
ByteBuffer buffer = jettyBuffer.getByteBuffer(); ByteBuffer buffer = jettyBuffer.getByteBuffer();
buffer.limit(jettyBuffer.putIndex()); buffer.limit(jettyBuffer.putIndex());
buffer.position(jettyBuffer.getIndex()); buffer.position(jettyBuffer.getIndex());
this.readBuffer = buffer; parser.parse(buffer);
}
parser.parse(readBuffer);
readBuffer = null;
return filled; return filled;
} }