Add a packetSize option to match the option on the native side.
authorjfclere <jfclere@13f79535-47bb-0310-9956-ffa450edef68>
Mon, 23 Oct 2006 09:15:22 +0000 (09:15 +0000)
committerjfclere <jfclere@13f79535-47bb-0310-9956-ffa450edef68>
Mon, 23 Oct 2006 09:15:22 +0000 (09:15 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk@466958 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/jk/common/ChannelNioSocket.java
java/org/apache/jk/common/ChannelSocket.java
java/org/apache/jk/common/MsgAjp.java
java/org/apache/jk/mbeans-descriptors.xml
java/org/apache/jk/server/JkMain.java

index 59af910..98da709 100644 (file)
@@ -99,6 +99,7 @@ public class ChannelNioSocket extends JkHandler
     private boolean nioIsBroken = false;
     private Selector selector = null;
     private int bufferSize = 8*1024;
+    private int packetSize = 8*1024;
 
     private long requestCount=0;
     
@@ -160,6 +161,17 @@ public class ChannelNioSocket extends JkHandler
         return bufferSize;
     }
 
+    public void setPacketSize(int ps) {
+        if(ps < 8*1024) {
+            ps = 8*1024;
+        }
+        packetSize = ps;
+    }
+
+    public int getPacketSize() {
+        return packetSize;
+    }
+
 
     /**
      * jmx:managed-attribute description="Bind on a specified address" access="READ_WRITE"
@@ -792,7 +804,7 @@ public class ChannelNioSocket extends JkHandler
 
     protected class SocketConnection implements ThreadPoolRunnable {
         MsgContext ep;
-        MsgAjp recv = new MsgAjp();
+        MsgAjp recv = new MsgAjp(packetSize);
         boolean inProgress = false;
 
         SocketConnection(MsgContext ep) {
index fe4255b..8bca7b2 100644 (file)
@@ -88,6 +88,7 @@ public class ChannelSocket extends JkHandler
     private int linger=100;
     private int socketTimeout;
     private int bufferSize = -1;
+    private int packetSize = 8*1024;
 
     private long requestCount=0;
     
@@ -205,6 +206,17 @@ public class ChannelSocket extends JkHandler
         return bufferSize;
     }
 
+    public void setPacketSize(int ps) {
+        if(ps < 8*1024) {
+            ps = 8*1024;
+        }
+        packetSize = ps;
+    }
+
+    public int getPacketSize() {
+        return packetSize;
+    }
+
     /** At startup we'll look for the first free port in the range.
         The difference between this port and the beggining of the range
         is the 'id'.
@@ -665,7 +677,7 @@ public class ChannelSocket extends JkHandler
      */
     void processConnection(MsgContext ep) {
         try {
-            MsgAjp recv=new MsgAjp();
+            MsgAjp recv=new MsgAjp(packetSize);
             while( running ) {
                 if(paused) { // Drop the connection on pause
                     break;
index 30114fb..642b270 100644 (file)
@@ -43,7 +43,7 @@ public class MsgAjp extends Msg {
         org.apache.juli.logging.LogFactory.getLog( MsgAjp.class );
 
     // that's the original buffer size in ajp13 - otherwise we'll get interoperability problems.
-    private byte buf[]=new byte[8*1024]; 
+    private byte buf[];
     // The current read or write position in the buffer
     private int pos;    
     /**
@@ -54,9 +54,31 @@ public class MsgAjp extends Msg {
      */
     private int len; 
 
+    /**
+     * The maximum packet size
+     */
+    private int bufsize;
 
+    /**
+     * Constructor that takes a buffer size
+     */
+    public MsgAjp(int bsize) {
+        if(bsize < 8*1024) {
+            bsize = 8*1024;
+        }
+        bufsize = bsize;
+        buf = new byte[bsize];
     
-    
+    }
+
+    /**
+     * No arg constructor.
+     * @deprecated Use the buffer size constructor.
+     */
+    public MsgAjp() {
+        this(8*1024);
+    }
+
     /**
      * Prepare this packet for accumulating a message from the container to
      * the web server.  Set the write position to just after the header
index b43af85..380185b 100644 (file)
@@ -50,6 +50,9 @@
           description="are worker threads on daemon mode"
                  type="boolean"
             writeable="false"/>
+    <attribute name="packetSize"
+          description="The maximum AJP packet size"
+          type="int" />
 
     <operation name="start"
                description="Start, if server socket no create call init"
index fae6eee..2ee487d 100644 (file)
@@ -488,7 +488,8 @@ public class JkMain implements MBeanRegistration
         replacements.put("timeout", "channelSocket.timeout");
         replacements.put("address", "channelSocket.address");            
         replacements.put("bufferSize", "channelSocket.bufferSize");
-        replacements.put("tomcatAuthentication", "request.tomcatAuthentication");            
+        replacements.put("tomcatAuthentication", "request.tomcatAuthentication");
+        replacements.put("packetSize", "channelSocket.packetSize");
     }
 
     private void preProcessProperties() {