- readTimeout should behave how it does for the HTTP connector (this is an optimizati...
authorremm <remm@13f79535-47bb-0310-9956-ffa450edef68>
Mon, 11 Dec 2006 01:32:05 +0000 (01:32 +0000)
committerremm <remm@13f79535-47bb-0310-9956-ffa450edef68>
Mon, 11 Dec 2006 01:32:05 +0000 (01:32 +0000)
  negative values.

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

java/org/apache/coyote/ajp/AjpAprProcessor.java

index 3ce901d..2422e8c 100644 (file)
@@ -90,10 +90,11 @@ public class AjpAprProcessor implements ActionHook {
         responseHeaderMessage = new AjpMessage(packetSize);
         bodyMessage = new AjpMessage(packetSize);
         
-        if (endpoint.getFirstReadTimeout() > 0) {
-            readTimeout = endpoint.getFirstReadTimeout() * 1000;
-        } else {
+        readTimeout = endpoint.getFirstReadTimeout() * 1000;
+        if (readTimeout == 0) {
             readTimeout = 100 * 1000;
+        } else if (readTimeout < 0) {
+            readTimeout = -1;
         }
 
         // Allocate input and output buffers
@@ -1024,8 +1025,9 @@ public class AjpAprProcessor implements ActionHook {
             inputBuffer.limit(inputBuffer.position());
             inputBuffer.position(0);
         }
+        int nRead;
         while (inputBuffer.remaining() < n) {
-            int nRead = Socket.recvbb
+            nRead = Socket.recvbb
                 (socket, inputBuffer.limit(),
                         inputBuffer.capacity() - inputBuffer.limit());
             if (nRead > 0) {
@@ -1056,10 +1058,17 @@ public class AjpAprProcessor implements ActionHook {
             inputBuffer.limit(inputBuffer.position());
             inputBuffer.position(0);
         }
+        int nRead;
         while (inputBuffer.remaining() < n) {
-            int nRead = Socket.recvbbt
-                (socket, inputBuffer.limit(),
+            if (readTimeout > 0) {
+                nRead = Socket.recvbbt
+                    (socket, inputBuffer.limit(),
                         inputBuffer.capacity() - inputBuffer.limit(), readTimeout);
+            } else {
+                nRead = Socket.recvbb
+                    (socket, inputBuffer.limit(),
+                        inputBuffer.capacity() - inputBuffer.limit());
+            }
             if (nRead > 0) {
                 inputBuffer.limit(inputBuffer.limit() + nRead);
             } else {
@@ -1193,7 +1202,7 @@ public class AjpAprProcessor implements ActionHook {
         throws IOException {
         if (outputBuffer.position() > 0) {
             if (Socket.sendbb(socket, 0, outputBuffer.position()) < 0) {
-                throw new IOException();
+                throw new IOException(sm.getString("ajpprocessor.failedsend"));
             }
             outputBuffer.clear();
         }