All, I took some of the Ajp13 work I've been doing on the 3.3 branch and applied it to the 3.2 sources. The two attached files contain a fix for the file upload bug. As with the 3.3 version, there are some changes to the mod_jk.so source files, so to get the full effect, you'll need to rebuild mod_jk.so and hook it up to apache again. Possibly, you'll get some benefit from just the java files, but I'm not certain how that will work out. WARNING: I have not had a chance to thoroughly test this fix. I do not think it is ready for inclusion in the "stable" 3.2 builds. I'm offering it here so that 3.2 users who have a great need for the ajp13 / file upload combination can give it a shot. Enjoy, -Dan -- Dan Milstein // [EMAIL PROTECTED]
Index: jk_ajp13_worker.c =================================================================== RCS file: /home/cvspublic/jakarta-tomcat/src/native/jk/Attic/jk_ajp13_worker.c,v retrieving revision 1.3.2.1 diff -u -r1.3.2.1 jk_ajp13_worker.c --- jk_ajp13_worker.c 2000/09/13 23:06:25 1.3.2.1 +++ jk_ajp13_worker.c 2000/12/14 05:27:50 @@ -267,7 +267,7 @@ read_buf += 4; /* leave some space for the buffer headers */ read_buf += 2; /* leave some space for the read length */ - if(read_fully_from_server(r, read_buf, len) <= 0) { + if(read_fully_from_server(r, read_buf, len) < 0) { jk_log(l, JK_LOG_ERROR, "read_into_msg_buff: Error - read_fully_from_server failed\n"); return JK_FALSE; @@ -331,23 +331,25 @@ case JK_AJP13_GET_BODY_CHUNK: { - unsigned len = (unsigned)jk_b_get_int(msg); + unsigned len = (unsigned)jk_b_get_int(msg); if(len > MAX_SEND_BODY_SZ) { len = MAX_SEND_BODY_SZ; } if(len > ep->left_bytes_to_send) { len = ep->left_bytes_to_send; - } - if(len > 0) { - if(read_into_msg_buff(ep, r, msg, l, len)) { - return JK_AJP13_HAS_RESPONSE; - } - - jk_log(l, JK_LOG_ERROR, - "Error ajp13_process_callback - read_into_msg_buff failed\n"); - return JK_INTERNAL_ERROR; } + if(len < 0) { + len = 0; + } + + if(read_into_msg_buff(ep, r, msg, l, len)) { + return JK_AJP13_HAS_RESPONSE; + } + + jk_log(l, JK_LOG_ERROR, + "Error ajp13_process_callback - read_into_msg_buff failed\n"); + return JK_INTERNAL_ERROR; } break;
Index: Ajp13ConnectorRequest.java =================================================================== RCS file: /home/cvspublic/jakarta-tomcat/src/share/org/apache/tomcat/service/connector/Attic/Ajp13ConnectorRequest.java,v retrieving revision 1.5.2.2 diff -u -r1.5.2.2 Ajp13ConnectorRequest.java --- Ajp13ConnectorRequest.java 2000/12/12 09:41:43 1.5.2.2 +++ Ajp13ConnectorRequest.java 2000/12/14 05:20:40 @@ -250,24 +250,43 @@ public int doRead() throws IOException { if(pos >= blen) { - refeelReadBuffer(); - } + if( ! refillReadBuffer()) { + return -1; + } + } return bodyBuff[pos++]; } public int doRead(byte[] b, int off, int len) throws IOException { - // XXXXXX Stupid, but the whole thing must be rewriten ( see super()! ) - for(int i = off ; i < (len + off) ; i++) { - int a = doRead(); - if(-1 == a) { - System.out.println("Y"); - return i-off; - } - b[i] = (byte)a; - } - - return len; + if(pos >= blen) { + if( ! refillReadBuffer()) { + return -1; + } + } + + int toCopy = len; + while(toCopy > 0) { + int bytesRemaining = blen - pos; + if(bytesRemaining < 0) + bytesRemaining = 0; + int c = bytesRemaining < toCopy ? bytesRemaining : toCopy; + + System.arraycopy(bodyBuff, pos, b, off, c); + + toCopy -= c; + + off += c; + pos += c; // In case we exactly consume the buffer + + if(toCopy > 0) { + if( ! refillReadBuffer()) { // Resets blen and pos + break; + } + } + } + + return len - toCopy; } public void recycle() @@ -283,7 +302,7 @@ this.in = new BufferedServletInputStream(this); } - public void refeelReadBuffer() throws IOException + public boolean refillReadBuffer() throws IOException { MsgBuffer msg = con.getMsgBuffer(); msg.appendByte(JK_AJP13_GET_BODY_CHUNK); @@ -298,5 +317,7 @@ blen = msg.peekInt(); pos = 0; msg.getBytes(bodyBuff); + + return (blen > 0); } }