From 7e20ada957567734915fc003ad093273b40e3386 Mon Sep 17 00:00:00 2001 From: jfclere Date: Mon, 23 Oct 2006 09:15:22 +0000 Subject: [PATCH] Add a packetSize option to match the option on the native side. 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 | 14 ++++++++++++- java/org/apache/jk/common/ChannelSocket.java | 14 ++++++++++++- java/org/apache/jk/common/MsgAjp.java | 26 +++++++++++++++++++++++-- java/org/apache/jk/mbeans-descriptors.xml | 3 +++ java/org/apache/jk/server/JkMain.java | 3 ++- 5 files changed, 55 insertions(+), 5 deletions(-) diff --git a/java/org/apache/jk/common/ChannelNioSocket.java b/java/org/apache/jk/common/ChannelNioSocket.java index 59af910c0..98da709b1 100644 --- a/java/org/apache/jk/common/ChannelNioSocket.java +++ b/java/org/apache/jk/common/ChannelNioSocket.java @@ -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) { diff --git a/java/org/apache/jk/common/ChannelSocket.java b/java/org/apache/jk/common/ChannelSocket.java index fe4255bd4..8bca7b2d1 100644 --- a/java/org/apache/jk/common/ChannelSocket.java +++ b/java/org/apache/jk/common/ChannelSocket.java @@ -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; diff --git a/java/org/apache/jk/common/MsgAjp.java b/java/org/apache/jk/common/MsgAjp.java index 30114fbdc..642b270f4 100644 --- a/java/org/apache/jk/common/MsgAjp.java +++ b/java/org/apache/jk/common/MsgAjp.java @@ -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 diff --git a/java/org/apache/jk/mbeans-descriptors.xml b/java/org/apache/jk/mbeans-descriptors.xml index b43af8576..380185b46 100644 --- a/java/org/apache/jk/mbeans-descriptors.xml +++ b/java/org/apache/jk/mbeans-descriptors.xml @@ -50,6 +50,9 @@ description="are worker threads on daemon mode" type="boolean" writeable="false"/> +