[jboss-svn-commits] JBL Code SVN: r6802 - labs/jbossweb/trunk/src/share/classes/org/apache/coyote/ajp
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Sat Oct 14 14:09:38 EDT 2006
Author: mladen.turk at jboss.com
Date: 2006-10-14 14:09:35 -0400 (Sat, 14 Oct 2006)
New Revision: 6802
Modified:
labs/jbossweb/trunk/src/share/classes/org/apache/coyote/ajp/AjpAprProcessor.java
labs/jbossweb/trunk/src/share/classes/org/apache/coyote/ajp/AjpAprProtocol.java
labs/jbossweb/trunk/src/share/classes/org/apache/coyote/ajp/AjpMessage.java
Log:
Update Ajp for variable packet size
Modified: labs/jbossweb/trunk/src/share/classes/org/apache/coyote/ajp/AjpAprProcessor.java
===================================================================
--- labs/jbossweb/trunk/src/share/classes/org/apache/coyote/ajp/AjpAprProcessor.java 2006-10-14 00:36:07 UTC (rev 6801)
+++ labs/jbossweb/trunk/src/share/classes/org/apache/coyote/ajp/AjpAprProcessor.java 2006-10-14 18:09:35 UTC (rev 6802)
@@ -74,7 +74,7 @@
// ----------------------------------------------------------- Constructors
- public AjpAprProcessor(AprEndpoint endpoint) {
+ public AjpAprProcessor(int packetSize, AprEndpoint endpoint) {
this.endpoint = endpoint;
@@ -86,6 +86,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 {
@@ -93,9 +97,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];
@@ -132,19 +136,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;
/**
@@ -268,7 +272,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);
@@ -279,7 +283,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();
@@ -288,7 +292,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);
@@ -582,6 +586,7 @@
// Set the given bytes as the content
ByteChunk bc = (ByteChunk) param;
bodyBytes.setBytes(bc.getBytes(), bc.getStart(), bc.getLength());
+ request.setContentLength(bc.getLength());
first = false;
empty = false;
replay = true;
Modified: labs/jbossweb/trunk/src/share/classes/org/apache/coyote/ajp/AjpAprProtocol.java
===================================================================
--- labs/jbossweb/trunk/src/share/classes/org/apache/coyote/ajp/AjpAprProtocol.java 2006-10-14 00:36:07 UTC (rev 6801)
+++ labs/jbossweb/trunk/src/share/classes/org/apache/coyote/ajp/AjpAprProtocol.java 2006-10-14 18:09:35 UTC (rev 6802)
@@ -106,6 +106,11 @@
/**
+ * AJP packet size.
+ */
+ protected int packetSize = Constants.MAX_PACKET_SIZE;
+
+ /**
* Adapter which will process the requests recieved by this endpoint.
*/
private Adapter adapter;
@@ -423,7 +428,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: labs/jbossweb/trunk/src/share/classes/org/apache/coyote/ajp/AjpMessage.java
===================================================================
--- labs/jbossweb/trunk/src/share/classes/org/apache/coyote/ajp/AjpMessage.java 2006-10-14 00:36:07 UTC (rev 6801)
+++ labs/jbossweb/trunk/src/share/classes/org/apache/coyote/ajp/AjpMessage.java 2006-10-14 18:09:35 UTC (rev 6802)
@@ -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;
/**
@@ -267,7 +275,7 @@
* @param numBytes The number of bytes to copy.
*/
public void appendBytes(byte[] b, int off, int numBytes) {
- if (pos + numBytes + 3 >= buf.length) {
+ if (pos + numBytes + 3 > buf.length) {
log.error(sm.getString("ajpmessage.overflow", "" + numBytes, "" + pos),
new ArrayIndexOutOfBoundsException());
if (log.isDebugEnabled()) {
@@ -374,6 +382,11 @@
}
+ public int getPacketSize() {
+ return buf.length;
+ }
+
+
public int processHeader() {
pos = 0;
int mark = getInt();
More information about the jboss-svn-commits
mailing list