jetty-9 fixed SSL issue. _inbound needed to be compacted
This commit is contained in:
parent
c1bcec61d5
commit
7ba514e250
|
@ -74,8 +74,8 @@ public class SslConnection extends AbstractConnection implements AsyncConnection
|
|||
|
||||
SslBuffers(int packetSize, int appSize)
|
||||
{
|
||||
_in=BufferUtil.allocate(packetSize);
|
||||
_out=BufferUtil.allocate(packetSize);
|
||||
_in=BufferUtil.allocateDirect(packetSize);
|
||||
_out=BufferUtil.allocateDirect(packetSize);
|
||||
_unwrap=BufferUtil.allocate(appSize);
|
||||
}
|
||||
}
|
||||
|
@ -163,6 +163,10 @@ public class SslConnection extends AbstractConnection implements AsyncConnection
|
|||
_inbound=null;
|
||||
_outbound=null;
|
||||
_unwrapBuf=null;
|
||||
_buffers._in.clear().limit(0);
|
||||
_buffers._out.clear().limit(0);
|
||||
_buffers._unwrap.clear().limit(0);
|
||||
|
||||
__buffers.set(_buffers);
|
||||
_buffers=null;
|
||||
}
|
||||
|
@ -324,10 +328,16 @@ public class SslConnection extends AbstractConnection implements AsyncConnection
|
|||
// Read any available data
|
||||
if (!BufferUtil.isAtCapacity(_inbound) && (filled=_endp.fill(_inbound))>0)
|
||||
progress = true;
|
||||
else
|
||||
_inbound.compact().flip();
|
||||
|
||||
// flush any output data
|
||||
if (!BufferUtil.isEmpty(_outbound) && (flushed=_endp.flush(_outbound))>0)
|
||||
{
|
||||
progress = true;
|
||||
_outbound.compact().flip();
|
||||
}
|
||||
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
|
@ -473,6 +483,8 @@ public class SslConnection extends AbstractConnection implements AsyncConnection
|
|||
{
|
||||
buffer.compact();
|
||||
result=_engine.unwrap(_inbound,buffer);
|
||||
buffer.flip();
|
||||
|
||||
if (_logger.isDebugEnabled())
|
||||
_logger.debug("{} unwrap {} {} consumed={} produced={}",
|
||||
_session,
|
||||
|
@ -480,7 +492,7 @@ public class SslConnection extends AbstractConnection implements AsyncConnection
|
|||
result.getHandshakeStatus(),
|
||||
result.bytesConsumed(),
|
||||
result.bytesProduced());
|
||||
buffer.flip();
|
||||
|
||||
}
|
||||
catch(SSLException e)
|
||||
{
|
||||
|
@ -492,8 +504,9 @@ public class SslConnection extends AbstractConnection implements AsyncConnection
|
|||
switch(result.getStatus())
|
||||
{
|
||||
case BUFFER_UNDERFLOW:
|
||||
_inbound.compact().flip();
|
||||
if (_endp.isInputShutdown())
|
||||
_inbound.clear();
|
||||
_inbound.clear().limit(0);
|
||||
break;
|
||||
|
||||
case BUFFER_OVERFLOW:
|
||||
|
|
|
@ -11,6 +11,7 @@ import java.io.BufferedInputStream;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.net.Socket;
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.nio.ByteBuffer;
|
||||
|
@ -25,6 +26,8 @@ import org.eclipse.jetty.io.AsyncEndPoint;
|
|||
import org.eclipse.jetty.io.BufferUtil;
|
||||
import org.eclipse.jetty.io.ConnectedEndPoint;
|
||||
import org.eclipse.jetty.io.EndPoint;
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.eclipse.jetty.util.TypeUtil;
|
||||
import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
|
@ -392,13 +395,15 @@ public class SelectChannelEndPointTest
|
|||
server.configureBlocking(false);
|
||||
|
||||
_manager.register(server);
|
||||
int writes = 100000;
|
||||
int writes = 10000;
|
||||
|
||||
final byte[] bytes="HelloWorld".getBytes("UTF-8");
|
||||
final byte[] bytes="HelloWorld-".getBytes(StringUtil.__UTF8_CHARSET);
|
||||
byte[] count="0\n".getBytes(StringUtil.__UTF8_CHARSET);
|
||||
final CountDownLatch latch = new CountDownLatch(writes);
|
||||
final InputStream in = new BufferedInputStream(client.getInputStream());
|
||||
final long start = System.currentTimeMillis();
|
||||
client.getOutputStream().write(bytes);
|
||||
client.getOutputStream().write(count);
|
||||
client.getOutputStream().flush();
|
||||
|
||||
new Thread()
|
||||
|
@ -416,6 +421,10 @@ public class SelectChannelEndPointTest
|
|||
assertTrue(b>0);
|
||||
assertEquals(0xff&b0,b);
|
||||
}
|
||||
|
||||
int b=in.read();
|
||||
while(b>0 && b!='\n')
|
||||
b=in.read();
|
||||
latch.countDown();
|
||||
}
|
||||
}
|
||||
|
@ -429,11 +438,18 @@ public class SelectChannelEndPointTest
|
|||
}.start();
|
||||
|
||||
|
||||
PrintStream print = new PrintStream(client.getOutputStream());
|
||||
|
||||
// Write client to server
|
||||
for (int i=1;i<writes;i++)
|
||||
{
|
||||
client.getOutputStream().write(bytes);
|
||||
print.write(bytes);
|
||||
print.print(i);
|
||||
print.print('\n');
|
||||
if (i%100==0)
|
||||
print.flush();
|
||||
Thread.yield();
|
||||
|
||||
}
|
||||
client.getOutputStream().flush();
|
||||
|
||||
|
|
Loading…
Reference in New Issue