pool and compress the unwrap buffer
This commit is contained in:
parent
32f7822c1a
commit
7e37d1a428
|
@ -73,11 +73,13 @@ public class SslConnection extends AbstractConnection implements AsyncConnection
|
|||
{
|
||||
final NIOBuffer _in;
|
||||
final NIOBuffer _out;
|
||||
final NIOBuffer _unwrap;
|
||||
|
||||
SslBuffers(int packetSize, int appSize)
|
||||
{
|
||||
_in=new IndirectNIOBuffer(packetSize);
|
||||
_out=new IndirectNIOBuffer(packetSize);
|
||||
_unwrap=new IndirectNIOBuffer(appSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -147,6 +149,7 @@ public class SslConnection extends AbstractConnection implements AsyncConnection
|
|||
_buffers=new SslBuffers(_session.getPacketBufferSize()*2,_session.getApplicationBufferSize()*2);
|
||||
_inbound=_buffers._in;
|
||||
_outbound=_buffers._out;
|
||||
_unwrapBuf=_buffers._unwrap;
|
||||
__buffers.set(null);
|
||||
}
|
||||
}
|
||||
|
@ -162,16 +165,15 @@ public class SslConnection extends AbstractConnection implements AsyncConnection
|
|||
{
|
||||
if (_buffers!=null &&
|
||||
_inbound.length()==0 &&
|
||||
_outbound.length()==0 )
|
||||
_outbound.length()==0 &&
|
||||
_unwrapBuf.length()==0)
|
||||
{
|
||||
_inbound=null;
|
||||
_outbound=null;
|
||||
_unwrapBuf=null;
|
||||
__buffers.set(_buffers);
|
||||
_buffers=null;
|
||||
}
|
||||
|
||||
if (_unwrapBuf!=null && _unwrapBuf.length()==0)
|
||||
_unwrapBuf=null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -241,10 +243,13 @@ public class SslConnection extends AbstractConnection implements AsyncConnection
|
|||
/* ------------------------------------------------------------ */
|
||||
private synchronized boolean process(Buffer toFill, Buffer toFlush) throws IOException
|
||||
{
|
||||
boolean some_progress=false;
|
||||
try
|
||||
{
|
||||
allocateBuffers();
|
||||
if (toFill==null)
|
||||
{
|
||||
if (_unwrapBuf==null)
|
||||
_unwrapBuf=new IndirectNIOBuffer(_session.getApplicationBufferSize()*2);
|
||||
_unwrapBuf.compact();
|
||||
toFill=_unwrapBuf;
|
||||
}
|
||||
else if (toFill.capacity()<_session.getApplicationBufferSize())
|
||||
|
@ -269,10 +274,6 @@ public class SslConnection extends AbstractConnection implements AsyncConnection
|
|||
toFlush=__ZERO_BUFFER;
|
||||
|
||||
boolean progress=true;
|
||||
boolean some_progress=false;
|
||||
try
|
||||
{
|
||||
allocateBuffers();
|
||||
|
||||
while (progress)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue