- Packet must be ended before sending.
authorremm <remm@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 13 Oct 2006 11:39:30 +0000 (11:39 +0000)
committerremm <remm@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 13 Oct 2006 11:39:30 +0000 (11:39 +0000)
- Fix off by one check bug in AjpMessage.
- Fix recycling bug (setting streams to null when doing keepalive is not a good idea).

git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk@463652 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/coyote/ajp/AjpMessage.java
java/org/apache/coyote/ajp/AjpProcessor.java

index ec5e69e..7b3bfd2 100644 (file)
@@ -275,7 +275,7 @@ public class AjpMessage {
      * @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()) {
@@ -382,6 +382,11 @@ public class AjpMessage {
     }
 
     
+    public int getPacketSize() {
+        return buf.length;
+    }
+    
+    
     public int processHeader() {
         pos = 0;
         int mark = getInt();
index 8c224d8..5d2a672 100644 (file)
@@ -428,7 +428,9 @@ public class AjpProcessor implements ActionHook {
 
         rp.setStage(org.apache.coyote.Constants.STAGE_ENDED);
         recycle();
-
+        input = null;
+        output = null;
+        
         return true;
 
     }
@@ -1062,9 +1064,6 @@ public class AjpProcessor implements ActionHook {
         response.recycle();
         certificates.recycle();
 
-        input = null;
-        output = null;
-        
     }
 
 
@@ -1157,7 +1156,9 @@ public class AjpProcessor implements ActionHook {
                 responseHeaderMessage.reset();
                 responseHeaderMessage.appendByte(Constants.JK_AJP13_SEND_BODY_CHUNK);
                 responseHeaderMessage.appendBytes(chunk.getBytes(), chunk.getOffset() + off, thisTime);
+                responseHeaderMessage.end();
                 output.write(responseHeaderMessage.getBuffer(), 0, responseHeaderMessage.getLen());
+
                 off += thisTime;
             }