diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslConnection.java b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslConnection.java index 5a401bf544c..f4cd2da46ad 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslConnection.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SslConnection.java @@ -51,13 +51,13 @@ public class SslConnection extends AbstractConnection implements AsyncConnection private static final NIOBuffer __ZERO_BUFFER=new IndirectNIOBuffer(0); - private final ThreadLocal __inBuffer = new ThreadLocal(); - private final ThreadLocal __outBuffer = new ThreadLocal(); + private static final ThreadLocal __buffers = new ThreadLocal(); private final SSLEngine _engine; private final SSLSession _session; private AsyncConnection _connection; private final SslEndPoint _sslEndPoint = new SslEndPoint(); private int _allocations; + private SslBuffers _buffers; private NIOBuffer _inbound; private NIOBuffer _unwrapBuf; private NIOBuffer _outbound; @@ -66,6 +66,23 @@ public class SslConnection extends AbstractConnection implements AsyncConnection private boolean _handshook; private boolean _oshut; + /* ------------------------------------------------------------ */ + /* this is a half baked buffer pool + */ + private static class SslBuffers + { + final NIOBuffer _in; + final NIOBuffer _out; + final NIOBuffer _unwrap; + + SslBuffers(int packetSize, int appSize) + { + System.err.println("New "+Thread.currentThread()); + _in=new IndirectNIOBuffer(packetSize); + _out=new IndirectNIOBuffer(packetSize); + _unwrap=new IndirectNIOBuffer(appSize); + } + } /* ------------------------------------------------------------ */ public SslConnection(SSLEngine engine,EndPoint endp) @@ -118,53 +135,51 @@ public class SslConnection extends AbstractConnection implements AsyncConnection { _allowRenegotiate = allowRenegotiate; } + + /* ------------------------------------------------------------ */ private void allocateBuffers() { synchronized (this) { if (_allocations++==0) { - if (_inbound==null) + if (_buffers==null) { - _inbound = __inBuffer.get(); - if (_inbound==null) - _inbound=new IndirectNIOBuffer(_session.getPacketBufferSize()*2); - } - - if (_outbound==null) - { - _outbound = __outBuffer.get(); - if (_outbound==null) - _outbound=new IndirectNIOBuffer(_session.getPacketBufferSize()*2); + _buffers=__buffers.get(); + if (_buffers==null) + _buffers=new SslBuffers(_session.getPacketBufferSize()*2,_session.getApplicationBufferSize()*2); + _inbound=_buffers._in; + _outbound=_buffers._out; + _unwrapBuf=_buffers._unwrap; + __buffers.set(null); } } } } - + + /* ------------------------------------------------------------ */ private void releaseBuffers() { synchronized (this) { if (--_allocations==0) { - if (_inbound!=null && _inbound.length()==0) + if (_buffers!=null && + _inbound.length()==0 && + _outbound.length()==0 && + _unwrapBuf.length()==0) { - __inBuffer.set(_inbound); _inbound=null; - } - - if (_outbound!=null && _outbound.length()==0) - { - __outBuffer.set(_outbound); _outbound=null; - } - - if (_unwrapBuf!=null && _unwrapBuf.length()==0) _unwrapBuf=null; + __buffers.set(_buffers); + _buffers=null; + } } } } - + + /* ------------------------------------------------------------ */ public Connection handle() throws IOException { try @@ -202,21 +217,25 @@ public class SslConnection extends AbstractConnection implements AsyncConnection return this; } + /* ------------------------------------------------------------ */ public boolean isIdle() { return false; } + /* ------------------------------------------------------------ */ public boolean isSuspended() { return false; } + /* ------------------------------------------------------------ */ public void onClose() { } + /* ------------------------------------------------------------ */ public void onInputShutdown() throws IOException { @@ -226,11 +245,7 @@ public class SslConnection extends AbstractConnection implements AsyncConnection private synchronized boolean process(Buffer toFill, Buffer toFlush) throws IOException { if (toFill==null) - { - if (_unwrapBuf==null) - _unwrapBuf=new IndirectNIOBuffer(_session.getApplicationBufferSize()*2); toFill=_unwrapBuf; - } else if (toFill.capacity()<_session.getApplicationBufferSize()) { boolean progress=process(null,toFlush); diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/NCSARequestLog.java b/jetty-server/src/main/java/org/eclipse/jetty/server/NCSARequestLog.java index 9ab01dc58ad..4382d46cc8d 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/NCSARequestLog.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/NCSARequestLog.java @@ -507,15 +507,7 @@ public class NCSARequestLog extends AbstractLifeCycle implements RequestLog buf.append("Async"); long responseLength = response.getContentCount(); - if (responseLength == 0) - { - System.err.println("Content-Length: "+response.getHeader("Content-Length")+" "+request.getConnection()+" "+request.getConnection().getEndPoint()); - new Throwable().printStackTrace(); - System.exit(1); - buf.append(' '); - buf.append('0'); - } - else if (responseLength >= 0) + if (responseLength >= 0) { buf.append(' '); if (responseLength > 99999) diff --git a/test-jetty-webapp/src/main/webapp/WEB-INF/web.xml b/test-jetty-webapp/src/main/webapp/WEB-INF/web.xml index 50f475ec36b..c08ca7fdbd9 100644 --- a/test-jetty-webapp/src/main/webapp/WEB-INF/web.xml +++ b/test-jetty-webapp/src/main/webapp/WEB-INF/web.xml @@ -36,7 +36,7 @@ org.eclipse.jetty.servlets.QoSFilter maxRequests - 20 + 10000 managedAttr