tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rj...@apache.org
Subject svn commit: r757708 - in /tomcat/trunk/java/org/apache: coyote/ajp/AjpAprProcessor.java coyote/ajp/AjpAprProtocol.java coyote/ajp/AjpProcessor.java coyote/ajp/AjpProtocol.java jk/common/ChannelNioSocket.java
Date Tue, 24 Mar 2009 10:41:07 GMT
Author: rjung
Date: Tue Mar 24 10:41:06 2009
New Revision: 757708

URL: http://svn.apache.org/viewvc?rev=757708&view=rev
Log:
Allow bigger AJP packets for request bodies and
responses (by setting packetSize on the connector).

Addition to r697192 for the other AJP connectors.

Modified:
    tomcat/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java
    tomcat/trunk/java/org/apache/coyote/ajp/AjpAprProtocol.java
    tomcat/trunk/java/org/apache/coyote/ajp/AjpProcessor.java
    tomcat/trunk/java/org/apache/coyote/ajp/AjpProtocol.java
    tomcat/trunk/java/org/apache/jk/common/ChannelNioSocket.java

Modified: tomcat/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java?rev=757708&r1=757707&r2=757708&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java Tue Mar 24 10:41:06 2009
@@ -86,10 +86,23 @@
         response.setOutputBuffer(new SocketOutputBuffer());
         request.setResponse(response);
 
+        this.packetSize = packetSize;
         requestHeaderMessage = new AjpMessage(packetSize);
         responseHeaderMessage = new AjpMessage(packetSize);
         bodyMessage = new AjpMessage(packetSize);
-        
+
+        // Set the get body message buffer
+        AjpMessage getBodyMessage = new AjpMessage(16);
+        getBodyMessage.reset();
+        getBodyMessage.appendByte(Constants.JK_AJP13_GET_BODY_CHUNK);
+        // Adjust allowed size if packetSize != default (Constants.MAX_PACKET_SIZE)
+        getBodyMessage.appendInt(Constants.MAX_READ_SIZE + packetSize - Constants.MAX_PACKET_SIZE);
+        getBodyMessage.end();
+        getBodyMessageBuffer =
+            ByteBuffer.allocateDirect(getBodyMessage.getLen());
+        getBodyMessageBuffer.put(getBodyMessage.getBuffer(), 0,
+                                 getBodyMessage.getLen());
+
         // Allocate input and output buffers
         inputBuffer = ByteBuffer.allocateDirect(packetSize * 2);
         inputBuffer.limit(0);
@@ -126,6 +139,12 @@
 
 
     /**
+     * The socket timeout used when reading the first block of the request
+     * header.
+     */
+    protected int packetSize;
+
+    /**
      * Header message. Note that this header is merely the one used during the
      * processing of the first message of a "request", so it might not be a request
      * header. It will stay unchanged during the processing of the whole request.
@@ -238,7 +257,7 @@
     /**
      * Direct buffer used for sending right away a get body message.
      */
-    protected static final ByteBuffer getBodyMessageBuffer;
+    protected final ByteBuffer getBodyMessageBuffer;
 
 
     /**
@@ -263,17 +282,6 @@
 
     static {
 
-        // Set the get body message buffer
-        AjpMessage getBodyMessage = new AjpMessage(16);
-        getBodyMessage.reset();
-        getBodyMessage.appendByte(Constants.JK_AJP13_GET_BODY_CHUNK);
-        getBodyMessage.appendInt(Constants.MAX_READ_SIZE);
-        getBodyMessage.end();
-        getBodyMessageBuffer =
-            ByteBuffer.allocateDirect(getBodyMessage.getLen());
-        getBodyMessageBuffer.put(getBodyMessage.getBuffer(), 0,
-                getBodyMessage.getLen());
-
         // Set the read body message buffer
         AjpMessage pongMessage = new AjpMessage(16);
         pongMessage.reset();
@@ -1284,7 +1292,8 @@
 
             int len = chunk.getLength();
             // 4 - hardcoded, byte[] marshalling overhead
-            int chunkSize = Constants.MAX_SEND_SIZE;
+            // Adjust allowed size if packetSize != default (Constants.MAX_PACKET_SIZE)
+            int chunkSize = Constants.MAX_SEND_SIZE + packetSize - Constants.MAX_PACKET_SIZE;
             int off = 0;
             while (len > 0) {
                 int thisTime = len;

Modified: tomcat/trunk/java/org/apache/coyote/ajp/AjpAprProtocol.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/ajp/AjpAprProtocol.java?rev=757708&r1=757707&r2=757708&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/ajp/AjpAprProtocol.java (original)
+++ tomcat/trunk/java/org/apache/coyote/ajp/AjpAprProtocol.java Tue Mar 24 10:41:06 2009
@@ -292,7 +292,13 @@
      */
     protected int packetSize = Constants.MAX_PACKET_SIZE;
     public int getPacketSize() { return packetSize; }
-    public void setPacketSize(int packetSize) { this.packetSize = packetSize; }
+    public void setPacketSize(int packetSize) {
+        if(packetSize < Constants.MAX_PACKET_SIZE) {
+            this.packetSize = Constants.MAX_PACKET_SIZE;
+        } else {
+            this.packetSize = packetSize;
+        }
+    }
 
     /**
      * The number of seconds Tomcat will wait for a subsequent request

Modified: tomcat/trunk/java/org/apache/coyote/ajp/AjpProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/ajp/AjpProcessor.java?rev=757708&r1=757707&r2=757708&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/ajp/AjpProcessor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/ajp/AjpProcessor.java Tue Mar 24 10:41:06 2009
@@ -86,10 +86,22 @@
         response.setOutputBuffer(new SocketOutputBuffer());
         request.setResponse(response);
 
+        this.packetSize = packetSize;
         requestHeaderMessage = new AjpMessage(packetSize);
         responseHeaderMessage = new AjpMessage(packetSize);
         bodyMessage = new AjpMessage(packetSize);
-        
+
+        // Set the get body message buffer
+        AjpMessage getBodyMessage = new AjpMessage(16);
+        getBodyMessage.reset();
+        getBodyMessage.appendByte(Constants.JK_AJP13_GET_BODY_CHUNK);
+        // Adjust allowed size if packetSize != default (Constants.MAX_PACKET_SIZE)
+        getBodyMessage.appendInt(Constants.MAX_READ_SIZE + packetSize - Constants.MAX_PACKET_SIZE);
+        getBodyMessage.end();
+        getBodyMessageArray = new byte[getBodyMessage.getLen()];
+        System.arraycopy(getBodyMessage.getBuffer(), 0, getBodyMessageArray, 
+                         0, getBodyMessage.getLen());
+
         // Cause loading of HexUtils
         HexUtils.load();
 
@@ -121,6 +133,12 @@
 
 
     /**
+     * The socket timeout used when reading the first block of the request
+     * header.
+     */
+    protected int packetSize;
+
+    /**
      * Header message. Note that this header is merely the one used during the
      * processing of the first message of a "request", so it might not be a request
      * header. It will stay unchanged during the processing of the whole request.
@@ -240,7 +258,7 @@
     /**
      * Direct buffer used for sending right away a get body message.
      */
-    protected static final byte[] getBodyMessageArray;
+    protected final byte[] getBodyMessageArray;
 
 
     /**
@@ -265,17 +283,6 @@
 
     static {
 
-        // Set the get body message buffer
-
-        AjpMessage getBodyMessage = new AjpMessage(16);
-        getBodyMessage.reset();
-        getBodyMessage.appendByte(Constants.JK_AJP13_GET_BODY_CHUNK);
-        getBodyMessage.appendInt(Constants.MAX_READ_SIZE);
-        getBodyMessage.end();
-        getBodyMessageArray = new byte[getBodyMessage.getLen()];
-        System.arraycopy(getBodyMessage.getBuffer(), 0, getBodyMessageArray, 
-                0, getBodyMessage.getLen());
-
         // Set the read body message buffer
         AjpMessage pongMessage = new AjpMessage(16);
         pongMessage.reset();
@@ -1223,7 +1230,8 @@
 
             int len = chunk.getLength();
             // 4 - hardcoded, byte[] marshalling overhead
-            int chunkSize = Constants.MAX_SEND_SIZE;
+            // Adjust allowed size if packetSize != default (Constants.MAX_PACKET_SIZE)
+            int chunkSize = Constants.MAX_SEND_SIZE + packetSize - Constants.MAX_PACKET_SIZE;
             int off = 0;
             while (len > 0) {
                 int thisTime = len;

Modified: tomcat/trunk/java/org/apache/coyote/ajp/AjpProtocol.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/ajp/AjpProtocol.java?rev=757708&r1=757707&r2=757708&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/ajp/AjpProtocol.java (original)
+++ tomcat/trunk/java/org/apache/coyote/ajp/AjpProtocol.java Tue Mar 24 10:41:06 2009
@@ -291,7 +291,13 @@
      */
     protected int packetSize = Constants.MAX_PACKET_SIZE;
     public int getPacketSize() { return packetSize; }
-    public void setPacketSize(int packetSize) { this.packetSize = packetSize; }
+    public void setPacketSize(int packetSize) {
+        if(packetSize < Constants.MAX_PACKET_SIZE) {
+            this.packetSize = Constants.MAX_PACKET_SIZE;
+        } else {
+            this.packetSize = packetSize;
+        }
+    }
 
     
     /**

Modified: tomcat/trunk/java/org/apache/jk/common/ChannelNioSocket.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jk/common/ChannelNioSocket.java?rev=757708&r1=757707&r2=757708&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jk/common/ChannelNioSocket.java (original)
+++ tomcat/trunk/java/org/apache/jk/common/ChannelNioSocket.java Tue Mar 24 10:41:06 2009
@@ -664,7 +664,7 @@
     void acceptConnections() {
         if( running ) {
             try{
-                MsgContext ep=createMsgContext();
+                MsgContext ep=createMsgContext(packetSize);
                 ep.setSource(this);
                 ep.setWorkerEnv( wEnv );
                 this.accept(ep);



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


Mime
View raw message