Author: remm
Date: Thu Sep 28 15:29:40 2006
New Revision: 451049

URL: http://svn.apache.org/viewvc?view=rev&rev=451049
Log:
- Add the new packetSize attribute.

Modified:
    tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java
    tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/AjpAprProtocol.java
    tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/AjpMessage.java
    tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/AjpProcessor.java
    tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/AjpProtocol.java

Modified: tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java?view=diff&rev=451049&r1=451048&r2=451049
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java 
(original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java Thu 
Sep 28 15:29:40 2006
@@ -73,7 +73,7 @@
     // ----------------------------------------------------------- Constructors
 
 
-    public AjpAprProcessor(AprEndpoint endpoint) {
+    public AjpAprProcessor(int packetSize, AprEndpoint endpoint) {
 
         this.endpoint = endpoint;
 
@@ -85,6 +85,10 @@
         response.setOutputBuffer(new SocketOutputBuffer());
         request.setResponse(response);
 
+        requestHeaderMessage = new AjpMessage(packetSize);
+        responseHeaderMessage = new AjpMessage(packetSize);
+        bodyMessage = new AjpMessage(packetSize);
+        
         if (endpoint.getFirstReadTimeout() > 0) {
             readTimeout = endpoint.getFirstReadTimeout() * 1000;
         } else {
@@ -92,9 +96,9 @@
         }
 
         // Allocate input and output buffers
-        inputBuffer = ByteBuffer.allocateDirect(Constants.MAX_PACKET_SIZE * 2);
+        inputBuffer = ByteBuffer.allocateDirect(packetSize * 2);
         inputBuffer.limit(0);
-        outputBuffer = ByteBuffer.allocateDirect(Constants.MAX_PACKET_SIZE * 
2);
+        outputBuffer = ByteBuffer.allocateDirect(packetSize * 2);
 
         // Cause loading of HexUtils
         int foo = HexUtils.DEC[0];
@@ -131,19 +135,19 @@
      * 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.
      */
-    protected AjpMessage requestHeaderMessage = new AjpMessage();
+    protected AjpMessage requestHeaderMessage = null;
 
 
     /**
      * Message used for response header composition.
      */
-    protected AjpMessage responseHeaderMessage = new AjpMessage();
+    protected AjpMessage responseHeaderMessage = null;
 
 
     /**
      * Body message.
      */
-    protected AjpMessage bodyMessage = new AjpMessage();
+    protected AjpMessage bodyMessage = null;
 
 
     /**
@@ -267,7 +271,7 @@
     static {
 
         // Set the get body message buffer
-        AjpMessage getBodyMessage = new AjpMessage();
+        AjpMessage getBodyMessage = new AjpMessage(128);
         getBodyMessage.reset();
         getBodyMessage.appendByte(Constants.JK_AJP13_GET_BODY_CHUNK);
         getBodyMessage.appendInt(Constants.MAX_READ_SIZE);
@@ -278,7 +282,7 @@
                 getBodyMessage.getLen());
 
         // Set the read body message buffer
-        AjpMessage pongMessage = new AjpMessage();
+        AjpMessage pongMessage = new AjpMessage(128);
         pongMessage.reset();
         pongMessage.appendByte(Constants.JK_AJP13_CPONG_REPLY);
         pongMessage.end();
@@ -287,7 +291,7 @@
                 pongMessage.getLen());
 
         // Allocate the end message array
-        AjpMessage endMessage = new AjpMessage();
+        AjpMessage endMessage = new AjpMessage(128);
         endMessage.reset();
         endMessage.appendByte(Constants.JK_AJP13_END_RESPONSE);
         endMessage.appendByte(1);
@@ -347,8 +351,6 @@
 
         // Error flag
         error = false;
-
-        long soTimeout = endpoint.getSoTimeout();
 
         int limit = 0;
         if (endpoint.getFirstReadTimeout() > 0) {

Modified: tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/AjpAprProtocol.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/AjpAprProtocol.java?view=diff&rev=451049&r1=451048&r2=451049
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/AjpAprProtocol.java 
(original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/AjpAprProtocol.java Thu Sep 
28 15:29:40 2006
@@ -108,6 +108,12 @@
 
 
     /**
+     * AJP packet size.
+     */
+    protected int packetSize = Constants.MAX_PACKET_SIZE;
+
+    
+    /**
      * Adapter which will process the requests recieved by this endpoint.
      */
     private Adapter adapter;
@@ -417,6 +423,16 @@
     }
     
     
+    public int getPacketSize() {
+        return packetSize;
+    }
+
+
+    public void setPacketSize(int i) {
+        packetSize = i;
+    }
+
+    
     // --------------------------------------  AjpConnectionHandler Inner Class
 
 
@@ -424,7 +440,7 @@
         protected AjpAprProtocol proto;
         protected static int count = 0;
         protected RequestGroupInfo global=new RequestGroupInfo();
-        protected ThreadLocal localProcessor = new ThreadLocal();
+        protected ThreadLocal<AjpAprProcessor> localProcessor = new 
ThreadLocal<AjpAprProcessor>();
 
         public AjpConnectionHandler(AjpAprProtocol proto) {
             this.proto = proto;
@@ -438,9 +454,9 @@
         public SocketState process(long socket) {
             AjpAprProcessor processor = null;
             try {
-                processor = (AjpAprProcessor) localProcessor.get();
+                processor = localProcessor.get();
                 if (processor == null) {
-                    processor = new AjpAprProcessor(proto.ep);
+                    processor = new AjpAprProcessor(proto.packetSize, 
proto.ep);
                     processor.setAdapter(proto.adapter);
                     
processor.setTomcatAuthentication(proto.tomcatAuthentication);
                     processor.setRequiredSecret(proto.requiredSecret);

Modified: tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/AjpMessage.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/AjpMessage.java?view=diff&rev=451049&r1=451048&r2=451049
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/AjpMessage.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/AjpMessage.java Thu Sep 28 
15:29:40 2006
@@ -47,13 +47,21 @@
         StringManager.getManager(Constants.Package);
 
 
+    // ------------------------------------------------------------ Constructor
+
+    
+    public AjpMessage(int packetSize) {
+        buf = new byte[packetSize];
+    }
+    
+
     // ----------------------------------------------------- Instance Variables
 
 
     /**
      * Fixed size buffer.
      */
-    protected byte buf[] = new byte[8 * 1024];
+    protected byte buf[] = null;
 
 
     /**

Modified: tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/AjpProcessor.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/AjpProcessor.java?view=diff&rev=451049&r1=451048&r2=451049
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/AjpProcessor.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/AjpProcessor.java Thu Sep 
28 15:29:40 2006
@@ -73,7 +73,7 @@
     // ----------------------------------------------------------- Constructors
 
 
-    public AjpProcessor(JIoEndpoint endpoint) {
+    public AjpProcessor(int packetSize, JIoEndpoint endpoint) {
 
         this.endpoint = endpoint;
 
@@ -85,6 +85,10 @@
         response.setOutputBuffer(new SocketOutputBuffer());
         request.setResponse(response);
 
+        requestHeaderMessage = new AjpMessage(packetSize);
+        responseHeaderMessage = new AjpMessage(packetSize);
+        bodyMessage = new AjpMessage(packetSize);
+        
         // Cause loading of HexUtils
         int foo = HexUtils.DEC[0];
 
@@ -120,19 +124,19 @@
      * 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.
      */
-    protected AjpMessage requestHeaderMessage = new AjpMessage();
+    protected AjpMessage requestHeaderMessage = null;
 
 
     /**
      * Message used for response header composition.
      */
-    protected AjpMessage responseHeaderMessage = new AjpMessage();
+    protected AjpMessage responseHeaderMessage = null;
 
 
     /**
      * Body message.
      */
-    protected AjpMessage bodyMessage = new AjpMessage();
+    protected AjpMessage bodyMessage = null;
 
 
     /**
@@ -256,7 +260,7 @@
     static {
 
         // Set the get body message buffer
-        AjpMessage getBodyMessage = new AjpMessage();
+        AjpMessage getBodyMessage = new AjpMessage(128);
         getBodyMessage.reset();
         getBodyMessage.appendByte(Constants.JK_AJP13_GET_BODY_CHUNK);
         getBodyMessage.appendInt(Constants.MAX_READ_SIZE);
@@ -266,7 +270,7 @@
                 0, getBodyMessage.getLen());
 
         // Set the read body message buffer
-        AjpMessage pongMessage = new AjpMessage();
+        AjpMessage pongMessage = new AjpMessage(128);
         pongMessage.reset();
         pongMessage.appendByte(Constants.JK_AJP13_CPONG_REPLY);
         pongMessage.end();
@@ -275,7 +279,7 @@
                 0, pongMessage.getLen());
 
         // Allocate the end message array
-        AjpMessage endMessage = new AjpMessage();
+        AjpMessage endMessage = new AjpMessage(128);
         endMessage.reset();
         endMessage.appendByte(Constants.JK_AJP13_END_RESPONSE);
         endMessage.appendByte(1);
@@ -335,8 +339,6 @@
 
         // Error flag
         error = false;
-
-        long soTimeout = endpoint.getSoTimeout();
 
         while (started && !error) {
 

Modified: tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/AjpProtocol.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/AjpProtocol.java?view=diff&rev=451049&r1=451048&r2=451049
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/AjpProtocol.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/coyote/ajp/AjpProtocol.java Thu Sep 28 
15:29:40 2006
@@ -108,6 +108,12 @@
 
 
     /**
+     * AJP packet size.
+     */
+    protected int packetSize = Constants.MAX_PACKET_SIZE;
+
+    
+    /**
      * Adapter which will process the requests recieved by this endpoint.
      */
     private Adapter adapter;
@@ -372,6 +378,16 @@
     }
     
     
+    public int getPacketSize() {
+        return packetSize;
+    }
+
+
+    public void setPacketSize(int i) {
+        packetSize = i;
+    }
+
+    
     // --------------------------------------  AjpConnectionHandler Inner Class
 
 
@@ -379,7 +395,7 @@
         protected AjpProtocol proto;
         protected static int count = 0;
         protected RequestGroupInfo global=new RequestGroupInfo();
-        protected ThreadLocal localProcessor = new ThreadLocal();
+        protected ThreadLocal<AjpProcessor> localProcessor = new 
ThreadLocal<AjpProcessor>();
 
         public AjpConnectionHandler(AjpProtocol proto) {
             this.proto = proto;
@@ -388,9 +404,9 @@
         public boolean process(Socket socket) {
             AjpProcessor processor = null;
             try {
-                processor = (AjpProcessor) localProcessor.get();
+                processor = localProcessor.get();
                 if (processor == null) {
-                    processor = new AjpProcessor(proto.ep);
+                    processor = new AjpProcessor(proto.packetSize, proto.ep);
                     processor.setAdapter(proto.adapter);
                     
processor.setTomcatAuthentication(proto.tomcatAuthentication);
                     processor.setRequiredSecret(proto.requiredSecret);



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to