You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2015/01/13 21:39:23 UTC

svn commit: r1651478 - in /tomcat/trunk/java/org/apache/coyote/http11: AbstractInputBuffer.java InternalAprInputBuffer.java InternalNio2InputBuffer.java InternalNioInputBuffer.java

Author: markt
Date: Tue Jan 13 20:39:22 2015
New Revision: 1651478

URL: http://svn.apache.org/r1651478
Log:
checkpoint
 - add readByteBuffer

Modified:
    tomcat/trunk/java/org/apache/coyote/http11/AbstractInputBuffer.java
    tomcat/trunk/java/org/apache/coyote/http11/InternalAprInputBuffer.java
    tomcat/trunk/java/org/apache/coyote/http11/InternalNio2InputBuffer.java
    tomcat/trunk/java/org/apache/coyote/http11/InternalNioInputBuffer.java

Modified: tomcat/trunk/java/org/apache/coyote/http11/AbstractInputBuffer.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/AbstractInputBuffer.java?rev=1651478&r1=1651477&r2=1651478&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/AbstractInputBuffer.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/AbstractInputBuffer.java Tue Jan 13 20:39:22 2015
@@ -118,10 +118,26 @@ public abstract class AbstractInputBuffe
 
 
     /**
-     * Pointer to the current read buffer.
+     * The read buffer represented as a byte[].
+     * <p>
+     * SocketWrapper uses ByteBuffer (since reading from socket to ByteBuffer is
+     * the only API common to all current I/O implementations) but this class
+     * uses byte[] since that is more efficient for parsing. readByteBuffer
+     * therefore wraps buf. The byte[] representation is only used for reading.
+     * The ByteBuffer representation is only used for writing.
      */
     protected byte[] buf;
 
+    /**
+     * The read buffer represented as a ByteBuffer.
+     * <p>
+     * SocketWrapper uses ByteBuffer (since reading from socket to ByteBuffer is
+     * the only API common to all current I/O implementations) but this class
+     * uses byte[] since that is more efficient for parsing. readByteBuffer
+     * therefore wraps buf. The byte[] representation is only used for reading.
+     * The ByteBuffer representation is only used for writing.
+     */
+    protected ByteBuffer readByteBuffer;
 
     /**
      * Last valid byte.
@@ -371,6 +387,7 @@ public abstract class AbstractInputBuffe
 
         // Reset pointers
         lastValid = lastValid - pos;
+        readByteBuffer.position(lastValid);
         pos = 0;
         lastActiveFilter = -1;
         parsingHeader = true;
@@ -631,6 +648,8 @@ public abstract class AbstractInputBuffe
             byte[] tmp = new byte[newsize];
             System.arraycopy(buf,0,tmp,0,buf.length);
             buf = tmp;
+            readByteBuffer = ByteBuffer.wrap(buf);
+            readByteBuffer.position(lastValid);
         }
     }
 

Modified: tomcat/trunk/java/org/apache/coyote/http11/InternalAprInputBuffer.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/InternalAprInputBuffer.java?rev=1651478&r1=1651477&r2=1651478&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/InternalAprInputBuffer.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/InternalAprInputBuffer.java Tue Jan 13 20:39:22 2015
@@ -17,6 +17,7 @@
 package org.apache.coyote.http11;
 
 import java.io.IOException;
+import java.nio.ByteBuffer;
 
 import org.apache.coyote.InputBuffer;
 import org.apache.coyote.Request;
@@ -84,6 +85,7 @@ public class InternalAprInputBuffer exte
         int bufLength = Math.max(headerBufferSize, 8192);
         if (buf == null || buf.length < bufLength) {
             buf = new byte[bufLength];
+            readByteBuffer = ByteBuffer.wrap(buf);
         }
     }
 

Modified: tomcat/trunk/java/org/apache/coyote/http11/InternalNio2InputBuffer.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/InternalNio2InputBuffer.java?rev=1651478&r1=1651477&r2=1651478&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/InternalNio2InputBuffer.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/InternalNio2InputBuffer.java Tue Jan 13 20:39:22 2015
@@ -146,6 +146,7 @@ public class InternalNio2InputBuffer ext
         int bufLength = headerBufferSize + socketReadBufferSize;
         if (buf == null || buf.length < bufLength) {
             buf = new byte[bufLength];
+            readByteBuffer = ByteBuffer.wrap(buf);
         }
 
         // Initialize the completion handler

Modified: tomcat/trunk/java/org/apache/coyote/http11/InternalNioInputBuffer.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/InternalNioInputBuffer.java?rev=1651478&r1=1651477&r2=1651478&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/InternalNioInputBuffer.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/InternalNioInputBuffer.java Tue Jan 13 20:39:22 2015
@@ -98,6 +98,7 @@ public class InternalNioInputBuffer exte
         int bufLength = headerBufferSize + socketReadBufferSize;
         if (buf == null || buf.length < bufLength) {
             buf = new byte[bufLength];
+            readByteBuffer = ByteBuffer.wrap(buf);
         }
 
         pool = ((NioEndpoint)endpoint).getSelectorPool();



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: svn commit: r1651478 - in /tomcat/trunk/java/org/apache/coyote/http11: AbstractInputBuffer.java InternalAprInputBuffer.java InternalNio2InputBuffer.java InternalNioInputBuffer.java

Posted by Mark Thomas <ma...@apache.org>.
On 13/01/2015 20:39, markt@apache.org wrote:
> Author: markt
> Date: Tue Jan 13 20:39:22 2015
> New Revision: 1651478
> 
> URL: http://svn.apache.org/r1651478
> Log:
> checkpoint
>  - add readByteBuffer
> 
> Modified:
>     tomcat/trunk/java/org/apache/coyote/http11/AbstractInputBuffer.java
>     tomcat/trunk/java/org/apache/coyote/http11/InternalAprInputBuffer.java
>     tomcat/trunk/java/org/apache/coyote/http11/InternalNio2InputBuffer.java
>     tomcat/trunk/java/org/apache/coyote/http11/InternalNioInputBuffer.java

Sorry for the noise. This was meant to be a local git commit.

It shouldn't break anything but if it does feel free to revert it.

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org