Author: remm Date: Thu Nov 24 06:04:48 2005 New Revision: 348735 URL: http://svn.apache.org/viewcvs?rev=348735&view=rev Log: - 37627:Fix buffering issue in the HTTP APR connector when a large buffer size was used for servlets. - Unfortunately the FIXME had never been addressed and the algorithm never implemented properly, unlike for the AJP connector.
Modified: tomcat/connectors/trunk/http11/src/java/org/apache/coyote/http11/InternalAprOutputBuffer.java tomcat/container/tc5.5.x/webapps/docs/changelog.xml Modified: tomcat/connectors/trunk/http11/src/java/org/apache/coyote/http11/InternalAprOutputBuffer.java URL: http://svn.apache.org/viewcvs/tomcat/connectors/trunk/http11/src/java/org/apache/coyote/http11/InternalAprOutputBuffer.java?rev=348735&r1=348734&r2=348735&view=diff ============================================================================== --- tomcat/connectors/trunk/http11/src/java/org/apache/coyote/http11/InternalAprOutputBuffer.java (original) +++ tomcat/connectors/trunk/http11/src/java/org/apache/coyote/http11/InternalAprOutputBuffer.java Thu Nov 24 06:04:48 2005 @@ -720,19 +720,20 @@ public int doWrite(ByteChunk chunk, Response res) throws IOException { - // FIXME: It would likely be more efficient to do a number of writes - // through the direct BB; however, the case should happen very rarely. - // An algorithm similar to ByteChunk.append may also be better. - if (chunk.getLength() > bbuf.capacity()) { - if (Socket.send(socket, chunk.getBuffer(), chunk.getStart(), - chunk.getLength()) < 0) { - throw new IOException(sm.getString("iib.failedwrite")); - } - } else { - if (bbuf.position() + chunk.getLength() > bbuf.capacity()) { + int len = chunk.getLength(); + int start = chunk.getStart(); + byte[] b = chunk.getBuffer(); + while (len > 0) { + int thisTime = len; + if (bbuf.position() == bbuf.capacity()) { flushBuffer(); } - bbuf.put(chunk.getBuffer(), chunk.getStart(), chunk.getLength()); + if (thisTime > bbuf.capacity() - bbuf.position()) { + thisTime = bbuf.capacity() - bbuf.position(); + } + bbuf.put(b, start, thisTime); + len = len - thisTime; + start = start + thisTime; } return chunk.getLength(); Modified: tomcat/container/tc5.5.x/webapps/docs/changelog.xml URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/webapps/docs/changelog.xml?rev=348735&r1=348734&r2=348735&view=diff ============================================================================== --- tomcat/container/tc5.5.x/webapps/docs/changelog.xml (original) +++ tomcat/container/tc5.5.x/webapps/docs/changelog.xml Thu Nov 24 06:04:48 2005 @@ -136,6 +136,10 @@ Fix crash which could occur with the HTTP APR connector when accessing request JMX objects outside of the processing of the said request (remm) </fix> + <fix> + <bug>37627</bug>: Fix buffering issue in the HTTP APR connector when a large buffer size was + used for servlets (remm) + </fix> </changelog> </subsection> <subsection name="Jasper"> --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]