remm 2005/05/18 02:25:08
Modified: http11/src/java/org/apache/coyote/http11
InternalAprOutputBuffer.java
Log:
- Fix write algorithm (at least a return was missing), which could likely be
improved further. Thanks to Jean-Francois for spotting the problem.
Revision Changes Path
1.4 +12 -7
jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/InternalAprOutputBuffer.java
Index: InternalAprOutputBuffer.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/InternalAprOutputBuffer.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- InternalAprOutputBuffer.java 14 May 2005 20:41:26 -0000 1.3
+++ InternalAprOutputBuffer.java 18 May 2005 09:25:08 -0000 1.4
@@ -743,15 +743,20 @@
public int doWrite(ByteChunk chunk, Response res)
throws IOException {
- if (bbuf.position() + chunk.getLength() > bbuf.capacity()) {
- flushBuffer();
- if (chunk.getLength() > bbuf.capacity()) {
- if (Socket.send(socket, chunk.getBuffer(),
chunk.getStart(),
- chunk.getLength()) < 0)
- throw new
IOException(sm.getString("iib.failedwrite"));
+ // 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()) {
+ flushBuffer();
+ }
+ bbuf.put(chunk.getBuffer(), chunk.getStart(),
chunk.getLength());
}
- bbuf.put(chunk.getBuffer(), chunk.getStart(), chunk.getLength());
return chunk.getLength();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]