Mercurial Hosting > luan
diff src/org/eclipse/jetty/io/nio/SslConnection.java @ 1062:4a50422596b6
fix JBuffer.getByteBuffer()
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Wed, 09 Nov 2016 02:04:02 -0700 |
parents | 4afdf0f0c5bc |
children | 158d1e6ac17f |
line wrap: on
line diff
--- a/src/org/eclipse/jetty/io/nio/SslConnection.java Tue Nov 08 05:54:53 2016 -0700 +++ b/src/org/eclipse/jetty/io/nio/SslConnection.java Wed Nov 09 02:04:02 2016 -0700 @@ -124,7 +124,7 @@ if (_buffers==null) _buffers=new SslBuffers(_session.getPacketBufferSize()*2,_session.getApplicationBufferSize()*2); _inbound=_buffers._in; - _outbound=_buffers._out; + _outbound = _buffers._out; _unwrapBuf=_buffers._unwrap; __buffers.set(null); } @@ -144,7 +144,7 @@ _unwrapBuf.remaining()==0) { _inbound=null; - _outbound=null; + _outbound = null; _unwrapBuf=null; __buffers.set(_buffers); _buffers=null; @@ -378,22 +378,20 @@ private synchronized boolean wrap(final JBuffer buffer) throws IOException { - ByteBuffer bbuf=extractByteBuffer(buffer); + ByteBuffer bbuf = buffer.getByteBuffer(); final SSLEngineResult result; synchronized(bbuf) { _outbound.compact(); - ByteBuffer out_buffer=_outbound.getByteBuffer(); + ByteBuffer out_buffer = _outbound.getByteBuffer().duplicate(); synchronized(out_buffer) { try { - bbuf.position(buffer.getIndex()); - bbuf.limit(buffer.putIndex()); - out_buffer.position(_outbound.putIndex()); + out_buffer.position(_outbound.limit()); out_buffer.limit(out_buffer.capacity()); - result=_engine.wrap(bbuf,out_buffer); + result = _engine.wrap(bbuf,out_buffer); if (_logger.isDebugEnabled()) _logger.debug("{} wrap {} {} consumed={} produced={}", _session, @@ -402,9 +400,7 @@ result.bytesConsumed(), result.bytesProduced()); - - buffer.skip(result.bytesConsumed()); - _outbound.setPutIndex(_outbound.putIndex()+result.bytesProduced()); + _outbound.limit(_outbound.limit()+result.bytesProduced()); } catch(SSLException e) { @@ -412,13 +408,6 @@ _endp.close(); throw e; } - finally - { - out_buffer.position(0); - out_buffer.limit(out_buffer.capacity()); - bbuf.position(0); - bbuf.limit(bbuf.capacity()); - } } } @@ -454,20 +443,18 @@ if (!_inbound.hasRemaining()) return false; - ByteBuffer bbuf=extractByteBuffer(buffer); + ByteBuffer bbuf = buffer.getByteBuffer().duplicate(); final SSLEngineResult result; synchronized(bbuf) { - ByteBuffer in_buffer=_inbound.getByteBuffer(); + ByteBuffer in_buffer = _inbound.getByteBuffer(); synchronized(in_buffer) { try { - bbuf.position(buffer.putIndex()); + bbuf.position(buffer.limit()); bbuf.limit(buffer.capacity()); - in_buffer.position(_inbound.getIndex()); - in_buffer.limit(_inbound.putIndex()); result=_engine.unwrap(in_buffer,bbuf); if (_logger.isDebugEnabled()) @@ -478,9 +465,8 @@ result.bytesConsumed(), result.bytesProduced()); - _inbound.skip(result.bytesConsumed()); _inbound.compact(); - buffer.setPutIndex(buffer.putIndex()+result.bytesProduced()); + buffer.limit(buffer.limit()+result.bytesProduced()); } catch(SSLException e) { @@ -488,13 +474,6 @@ _endp.close(); throw e; } - finally - { - in_buffer.position(0); - in_buffer.limit(in_buffer.capacity()); - bbuf.position(0); - bbuf.limit(bbuf.capacity()); - } } } @@ -530,12 +509,6 @@ return result.bytesConsumed()>0 || result.bytesProduced()>0; } - - private ByteBuffer extractByteBuffer(JBuffer buffer) - { - return buffer.getByteBuffer(); - } - public SslEndPoint getSslEndPoint() { return _sslEndPoint;