Return-Path: Delivered-To: apmail-tomcat-dev-archive@www.apache.org Received: (qmail 3255 invoked from network); 12 Dec 2006 18:16:34 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 12 Dec 2006 18:16:34 -0000 Received: (qmail 98529 invoked by uid 500); 12 Dec 2006 18:16:36 -0000 Delivered-To: apmail-tomcat-dev-archive@tomcat.apache.org Received: (qmail 98460 invoked by uid 500); 12 Dec 2006 18:16:36 -0000 Mailing-List: contact dev-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Developers List" Delivered-To: mailing list dev@tomcat.apache.org Received: (qmail 98449 invoked by uid 99); 12 Dec 2006 18:16:36 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 12 Dec 2006 10:16:36 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: neutral (herse.apache.org: local policy) Received: from [72.254.0.201] (HELO s-utl01-sjpop.stsn.net) (72.254.0.201) by apache.org (qpsmtpd/0.29) with SMTP; Tue, 12 Dec 2006 10:16:26 -0800 Received: from s-utl01-sjpop.stsn.net ([127.0.0.1]) by s-utl01-sjpop.stsn.net (SMSSMTP 4.1.2.20) with SMTP id M2006121210160518511 for ; Tue, 12 Dec 2006 10:16:05 -0800 X-Spam-Level: Received: from [10.67.191.147] ([10.67.191.147]) by s-utl01-sjpop.stsn.net for dev@tomcat.apache.org; Tue, 12 Dec 2006 10:16:04 -0800 Message-ID: <457EF1DE.2070301@hanik.com> Date: Tue, 12 Dec 2006 12:15:58 -0600 From: Filip Hanik - Dev Lists User-Agent: Thunderbird 1.5.0.8 (Windows/20061025) MIME-Version: 1.0 To: Tomcat Developers List Subject: Re: svn commit: r486216 - in /tomcat/connectors/trunk/jk/java/org/apache/coyote/ajp: AjpAprProcessor.java AjpAprProtocol.java AjpMessage.java References: <20061212163413.089E91A981A@eris.apache.org> In-Reply-To: <20061212163413.089E91A981A@eris.apache.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Old-Spam-Status: No, hits=0.0 required=9.9 tests=ALL_TRUSTED: -2.867,AWL: -0.500,BAYES_00: -1.665, SARE_SUB_LONG_SUBJ_140: 1,SARE_SUB_MOBFU_2: 0.712 tabs used instead of spaces pero@apache.org wrote: > Author: pero > Date: Tue Dec 12 08:34:12 2006 > New Revision: 486216 > > URL: http://svn.apache.org/viewvc?view=rev&rev=486216 > Log: > Backport AJP packetSize handling from Tomcat 6.0.x > Add support to send and receive more the 8K BODY packets. > > Modified: > tomcat/connectors/trunk/jk/java/org/apache/coyote/ajp/AjpAprProcessor.java > tomcat/connectors/trunk/jk/java/org/apache/coyote/ajp/AjpAprProtocol.java > tomcat/connectors/trunk/jk/java/org/apache/coyote/ajp/AjpMessage.java > > Modified: tomcat/connectors/trunk/jk/java/org/apache/coyote/ajp/AjpAprProcessor.java > URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/java/org/apache/coyote/ajp/AjpAprProcessor.java?view=diff&rev=486216&r1=486215&r2=486216 > ============================================================================== > --- tomcat/connectors/trunk/jk/java/org/apache/coyote/ajp/AjpAprProcessor.java (original) > +++ tomcat/connectors/trunk/jk/java/org/apache/coyote/ajp/AjpAprProcessor.java Tue Dec 12 08:34:12 2006 > @@ -75,7 +75,7 @@ > // ----------------------------------------------------------- Constructors > > > - public AjpAprProcessor(AprEndpoint endpoint) { > + public AjpAprProcessor(int packetSize, AprEndpoint endpoint) { > > this.endpoint = endpoint; > > @@ -84,9 +84,13 @@ > > response = new Response(); > response.setHook(this); > - response.setOutputBuffer(new SocketOutputBuffer()); > + response.setOutputBuffer(new SocketOutputBuffer(packetSize)); > request.setResponse(response); > > + requestHeaderMessage = new AjpMessage(packetSize); > + responseHeaderMessage = new AjpMessage(packetSize); > + bodyMessage = new AjpMessage(packetSize); > + > if (endpoint.getFirstReadTimeout() > 0) { > readTimeout = endpoint.getFirstReadTimeout() * 1000; > } else { > @@ -94,15 +98,27 @@ > } > > // 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]; > > // Cause loading of HttpMessages > HttpMessages.getMessage(200); > + > + // Set the get body message buffer > + AjpMessage getBodyMessage = new AjpMessage(128); > + getBodyMessage.reset(); > + getBodyMessage.appendByte(Constants.JK_AJP13_GET_BODY_CHUNK); > + getBodyMessage.appendInt(packetSize -Constants.H_SIZE - 2); > + getBodyMessage.end(); > + getBodyMessageBuffer = > + ByteBuffer.allocateDirect(getBodyMessage.getLen()); > + getBodyMessageBuffer.put(getBodyMessage.getBuffer(), 0, > + getBodyMessage.getLen()); > + > > } > > @@ -133,19 +149,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 ; > > > /** > * Message used for response header composition. > */ > - protected AjpMessage responseHeaderMessage = new AjpMessage(); > + protected AjpMessage responseHeaderMessage ; > > > /** > * Body message. > */ > - protected AjpMessage bodyMessage = new AjpMessage(); > + protected AjpMessage bodyMessage ; > > > /** > @@ -248,7 +264,7 @@ > /** > * Direct buffer used for sending right away a get body message. > */ > - protected static final ByteBuffer getBodyMessageBuffer; > + protected ByteBuffer getBodyMessageBuffer; > > > /** > @@ -272,19 +288,9 @@ > > static { > > - // Set the get body message buffer > - AjpMessage getBodyMessage = new AjpMessage(); > - 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(); > + AjpMessage pongMessage = new AjpMessage(128); > pongMessage.reset(); > pongMessage.appendByte(Constants.JK_AJP13_CPONG_REPLY); > pongMessage.end(); > @@ -293,7 +299,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); > @@ -303,7 +309,7 @@ > endMessage.getLen()); > > // Set the flush message buffer > - AjpMessage flushMessage = new AjpMessage(); > + AjpMessage flushMessage = new AjpMessage(128); > flushMessage.reset(); > flushMessage.appendByte(Constants.JK_AJP13_SEND_BODY_CHUNK); > flushMessage.appendInt(0); > @@ -369,8 +375,6 @@ > // Error flag > error = false; > > - long soTimeout = endpoint.getSoTimeout(); > - > int limit = 0; > if (endpoint.getFirstReadTimeout() > 0) { > limit = endpoint.getMaxThreads() / 2; > @@ -1249,7 +1253,12 @@ > protected class SocketOutputBuffer > implements OutputBuffer { > > - > + int maxSendPacketSize ; > + > + SocketOutputBuffer(int maxSendSize) { > + this.maxSendPacketSize = maxSendSize - Constants.H_SIZE - 4 ; > + } > + > /** > * Write chunk. > */ > @@ -1268,7 +1277,7 @@ > > int len = chunk.getLength(); > // 4 - hardcoded, byte[] marshalling overhead > - int chunkSize = Constants.MAX_SEND_SIZE; > + int chunkSize = maxSendPacketSize ; > int off = 0; > while (len > 0) { > int thisTime = len; > > Modified: tomcat/connectors/trunk/jk/java/org/apache/coyote/ajp/AjpAprProtocol.java > URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/java/org/apache/coyote/ajp/AjpAprProtocol.java?view=diff&rev=486216&r1=486215&r2=486216 > ============================================================================== > --- tomcat/connectors/trunk/jk/java/org/apache/coyote/ajp/AjpAprProtocol.java (original) > +++ tomcat/connectors/trunk/jk/java/org/apache/coyote/ajp/AjpAprProtocol.java Tue Dec 12 08:34:12 2006 > @@ -107,6 +107,12 @@ > > > /** > + * AJP packet size. > + */ > + protected int packetSize = Constants.MAX_PACKET_SIZE; > + > + > + /** > * Adapter which will process the requests recieved by this endpoint. > */ > private Adapter adapter; > @@ -405,6 +411,19 @@ > this.requiredSecret = requiredSecret; > } > > + > + public int getPacketSize() { > + return packetSize; > + } > + > + > + public void setPacketSize(int packetSize) { > + if(packetSize + packetSize = Constants.MAX_PACKET_SIZE; > + } > + this.packetSize = packetSize; > + } > + > > // -------------------------------------- AjpConnectionHandler Inner Class > > @@ -424,7 +443,7 @@ > try { > processor = (AjpAprProcessor) 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/connectors/trunk/jk/java/org/apache/coyote/ajp/AjpMessage.java > URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/java/org/apache/coyote/ajp/AjpMessage.java?view=diff&rev=486216&r1=486215&r2=486216 > ============================================================================== > --- tomcat/connectors/trunk/jk/java/org/apache/coyote/ajp/AjpMessage.java (original) > +++ tomcat/connectors/trunk/jk/java/org/apache/coyote/ajp/AjpMessage.java Tue Dec 12 08:34:12 2006 > @@ -47,14 +47,19 @@ > protected static StringManager sm = > 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 ; > > > /** > @@ -71,7 +76,7 @@ > */ > protected int len; > > - > + > // --------------------------------------------------------- Public Methods > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org > For additional commands, e-mail: dev-help@tomcat.apache.org > > > > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org For additional commands, e-mail: dev-help@tomcat.apache.org