Mercurial Hosting > luan
diff src/org/eclipse/jetty/io/nio/SslConnection.java @ 1048:2b769da7f67d
remove Buffer
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 07 Nov 2016 23:15:42 -0700 |
parents | a8c92b0a08ed |
children | 4afdf0f0c5bc |
line wrap: on
line diff
--- a/src/org/eclipse/jetty/io/nio/SslConnection.java Mon Nov 07 22:51:09 2016 -0700 +++ b/src/org/eclipse/jetty/io/nio/SslConnection.java Mon Nov 07 23:15:42 2016 -0700 @@ -30,7 +30,7 @@ import org.eclipse.jetty.io.AbstractConnection; import org.eclipse.jetty.io.AsyncEndPoint; -import org.eclipse.jetty.io.Buffer; +import org.eclipse.jetty.io.JBuffer; import org.eclipse.jetty.io.BufferUtil; import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.server.AsyncHttpConnection; @@ -51,7 +51,7 @@ { private final Logger _logger = LoggerFactory.getLogger("org.eclipse.jetty.io.nio.ssl"); - private static final NIOBuffer __ZERO_BUFFER = BufferUtil.EMPTY_BUFFER; + private static final JBuffer __ZERO_BUFFER = BufferUtil.EMPTY_BUFFER; private static final ThreadLocal<SslBuffers> __buffers = new ThreadLocal<SslBuffers>(); private final SSLEngine _engine; @@ -60,9 +60,9 @@ private final SslEndPoint _sslEndPoint; private int _allocations; private SslBuffers _buffers; - private NIOBuffer _inbound; - private NIOBuffer _unwrapBuf; - private NIOBuffer _outbound; + private JBuffer _inbound; + private JBuffer _unwrapBuf; + private JBuffer _outbound; private final AsyncEndPoint _aEndp; private boolean _allowRenegotiate = true; private boolean _handshook; @@ -75,9 +75,9 @@ */ private static class SslBuffers { - final NIOBuffer _in; - final NIOBuffer _out; - final NIOBuffer _unwrap; + final JBuffer _in; + final JBuffer _out; + final JBuffer _unwrap; SslBuffers(int packetSize, int appSize) { @@ -209,7 +209,7 @@ { } - private synchronized boolean process(Buffer toFill, Buffer toFlush) throws IOException + private synchronized boolean process(JBuffer toFill, JBuffer toFlush) throws IOException { boolean some_progress=false; try @@ -376,7 +376,7 @@ } } - private synchronized boolean wrap(final Buffer buffer) throws IOException + private synchronized boolean wrap(final JBuffer buffer) throws IOException { ByteBuffer bbuf=extractByteBuffer(buffer); final SSLEngineResult result; @@ -449,7 +449,7 @@ return result.bytesConsumed()>0 || result.bytesProduced()>0; } - private synchronized boolean unwrap(final Buffer buffer) throws IOException + private synchronized boolean unwrap(final JBuffer buffer) throws IOException { if (!_inbound.hasRemaining()) return false; @@ -532,11 +532,9 @@ } - private ByteBuffer extractByteBuffer(Buffer buffer) + private ByteBuffer extractByteBuffer(JBuffer buffer) { - if (buffer.buffer() instanceof NIOBuffer) - return ((NIOBuffer)buffer.buffer()).getByteBuffer(); - return ByteBuffer.wrap(buffer.array()); + return buffer.getByteBuffer(); } public SslEndPoint getSslEndPoint() @@ -604,7 +602,7 @@ _endp.close(); } - public int fill(Buffer buffer) throws IOException + public int fill(JBuffer buffer) throws IOException { int size=buffer.remaining(); process(buffer, null); @@ -616,14 +614,14 @@ return filled; } - public int flush(Buffer buffer) throws IOException + public int flush(JBuffer buffer) throws IOException { int size = buffer.remaining(); process(null, buffer); return size-buffer.remaining(); } - public int flush(Buffer header, Buffer buffer, Buffer trailer) throws IOException + public int flush(JBuffer header, JBuffer buffer, JBuffer trailer) throws IOException { if (header!=null && header.hasRemaining()) return flush(header); @@ -735,9 +733,9 @@ // Do NOT use synchronized (SslConnection.this) // because it's very easy to deadlock when debugging is enabled. // We do a best effort to print the right toString() and that's it. - Buffer inbound = _inbound; - Buffer outbound = _outbound; - Buffer unwrap = _unwrapBuf; + JBuffer inbound = _inbound; + JBuffer outbound = _outbound; + JBuffer unwrap = _unwrapBuf; int i = inbound == null? -1 : inbound.remaining(); int o = outbound == null ? -1 : outbound.remaining(); int u = unwrap == null ? -1 : unwrap.remaining();