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,28 +87,18 @@ 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 NIOBuffer jettyBuffer = new DirectNIOBuffer(4096);
// or eventually read more bytes and parse them. AsyncEndPoint endPoint = getEndPoint();
int filled = endPoint.fill(jettyBuffer);
logger.debug("Filled {} from {}", filled, endPoint);
if (filled <= 0)
return filled;
int filled = 0; ByteBuffer buffer = jettyBuffer.getByteBuffer();
if (readBuffer == null) buffer.limit(jettyBuffer.putIndex());
{ buffer.position(jettyBuffer.getIndex());
// TODO: use buffer pool ? parser.parse(buffer);
NIOBuffer jettyBuffer = new DirectNIOBuffer(4096);
AsyncEndPoint endPoint = getEndPoint();
filled = endPoint.fill(jettyBuffer);
logger.debug("Filled {} from {}", filled, endPoint);
if (filled <= 0)
return filled;
ByteBuffer buffer = jettyBuffer.getByteBuffer();
buffer.limit(jettyBuffer.putIndex());
buffer.position(jettyBuffer.getIndex());
this.readBuffer = buffer;
}
parser.parse(readBuffer);
readBuffer = null;
return filled; return filled;
} }