changeset 1072:00704b28b9f1

remove JBuffer.skip()
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 10 Nov 2016 02:29:01 -0700
parents b4ba8a4d5a16
children 6e511ea557b4
files src/org/eclipse/jetty/io/JBuffer.java src/org/eclipse/jetty/io/nio/SslConnection.java
diffstat 2 files changed, 17 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/org/eclipse/jetty/io/JBuffer.java	Thu Nov 10 02:13:28 2016 -0700
+++ b/src/org/eclipse/jetty/io/JBuffer.java	Thu Nov 10 02:29:01 2016 -0700
@@ -133,11 +133,6 @@
 		return put(b,0,b.length);
 	}
 
-	public void skip(int n) {
-		if (remaining() < n) n = remaining();
-		bb.position(bb.position() + n);
-	}
-
 	private final byte[] asArray() {
 		byte[] bytes = new byte[remaining()];
 		bb.duplicate().get(bytes);
--- a/src/org/eclipse/jetty/io/nio/SslConnection.java	Thu Nov 10 02:13:28 2016 -0700
+++ b/src/org/eclipse/jetty/io/nio/SslConnection.java	Thu Nov 10 02:29:01 2016 -0700
@@ -128,7 +128,7 @@
 						_buffers=new SslBuffers(_session.getPacketBufferSize()*2,_session.getApplicationBufferSize()*2);
 					_inbound = _buffers._in;
 					_outbound = _buffers._out;
-					_unwrapBuf=_buffers._unwrap;
+					_unwrapBuf = _buffers._unwrap;
 					__buffers.set(null);
 				}
 			}
@@ -171,7 +171,7 @@
 
 				// If we are handshook let the delegate connection
 				if (_engine.getHandshakeStatus()!=HandshakeStatus.NOT_HANDSHAKING)
-					progress=process(null,null);
+					progress = process(null,null);
 
 				// handle the delegate connection
 				_connection.handle();
@@ -212,6 +212,14 @@
 	{
 	}
 
+	private void put_unwrapBuf(JBuffer toFill) {
+		JBuffer dup = toFill.duplicate();
+		dup.position(dup.limit());
+		dup.limit(dup.capacity());
+		dup.putQ(_unwrapBuf);
+		toFill.limit(dup.position());
+	}
+
 	private synchronized boolean process(JBuffer toFill, JBuffer toFlush) throws IOException
 	{
 		boolean some_progress=false;
@@ -225,19 +233,20 @@
 			{
 				// use the unwrapbuffer to hold received data.
 				BufferUtil.compact(_unwrapBuf);
-				toFill=_unwrapBuf;
+				toFill = _unwrapBuf;
 			}
 			// Else if the fill buffer is too small for the SSL session
 			else if (toFill.capacity()<_session.getApplicationBufferSize())
 			{
 				// fill to the temporary unwrapBuffer
-				boolean progress=process(null,toFlush);
+				boolean progress = process(null,toFlush);
 
 				// if we received any data,
 				if (_unwrapBuf!=null && _unwrapBuf.hasRemaining())
 				{
 					// transfer from temp buffer to fill buffer
-					_unwrapBuf.skip(toFill.put(_unwrapBuf));
+//					_unwrapBuf.skip(toFill.putJ(_unwrapBuf));
+					put_unwrapBuf(toFill);
 					return true;
 				}
 				else
@@ -248,7 +257,8 @@
 			else if (_unwrapBuf!=null && _unwrapBuf.hasRemaining())
 			{
 				// transfer from temp buffer to fill buffer
-				_unwrapBuf.skip(toFill.put(_unwrapBuf));
+//				_unwrapBuf.skip(toFill.putJ(_unwrapBuf));
+				put_unwrapBuf(toFill);
 				return true;
 			}
 
@@ -579,7 +589,7 @@
 
 		public int fill(JBuffer buffer) throws IOException
 		{
-			int size=buffer.remaining();
+			int size = buffer.remaining();
 			process(buffer, null);
 
 			int filled=buffer.remaining()-size;