since we are writing on a piggy back thread, better make it thread safe in case there...
authorfhanik <fhanik@13f79535-47bb-0310-9956-ffa450edef68>
Mon, 10 Jul 2006 14:20:00 +0000 (14:20 +0000)
committerfhanik <fhanik@13f79535-47bb-0310-9956-ffa450edef68>
Mon, 10 Jul 2006 14:20:00 +0000 (14:20 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk@420538 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/coyote/http11/InternalNioInputBuffer.java
java/org/apache/coyote/http11/InternalNioOutputBuffer.java

index 44d102f..d8765c3 100644 (file)
@@ -542,7 +542,7 @@ public class InternalNioInputBuffer implements InputBuffer {
      * Perform blocking read with a timeout if desired\r
      * @param timeout boolean - set to true if the system will time out\r
      * @return boolean - true if data was read, false is EOF is reached\r
-     * @throws IOException\r
+     * @throws IOException \r
      */\r
     private boolean readSocket(boolean timeout) throws IOException {\r
         int nRead = 0;\r
index 3dfb331..265927e 100644 (file)
@@ -394,25 +394,18 @@ public class InternalNioOutputBuffer
         if (!committed) {\r
             //Socket.send(socket, Constants.ACK_BYTES, 0, Constants.ACK_BYTES.length) < 0\r
             ByteBuffer buf = ByteBuffer.wrap(Constants.ACK_BYTES,0,Constants.ACK_BYTES.length);    \r
-            writeToSocket(buf);\r
+            writeToSocket(buf,false);\r
         }\r
 \r
     }\r
 \r
-    private void writeToSocket(ByteBuffer bytebuffer) throws IOException {\r
+    private synchronized void writeToSocket(ByteBuffer bytebuffer, boolean flip) throws IOException {\r
         int limit = bytebuffer.position();\r
-        bytebuffer.rewind();\r
-        bytebuffer.limit(limit);\r
-        int remaining = limit;\r
-        while ( remaining > 0 ) {\r
+        if ( flip ) bytebuffer.flip();\r
+        while ( bytebuffer.hasRemaining() ) {\r
             int written = socket.write(bytebuffer);\r
-            remaining -= written;\r
         }\r
         bbuf.clear();\r
-        bbuf.rewind();\r
-        bbuf.limit(bbufLimit);\r
-\r
-        //System.out.println("Written:"+limit);\r
         this.total = 0;\r
     } \r
 \r
@@ -735,7 +728,7 @@ public class InternalNioOutputBuffer
 \r
         //write to the socket, if there is anything to write\r
         if (bbuf.position() > 0) {\r
-            writeToSocket(bbuf);\r
+            writeToSocket(bbuf,true);\r
         }\r
     }\r
 \r