From 30cab3b809aa329b00bb61b1a5f80478d3896f31 Mon Sep 17 00:00:00 2001 From: remm Date: Mon, 11 Dec 2006 01:32:05 +0000 Subject: [PATCH] - readTimeout should behave how it does for the HTTP connector (this is an optimization), so add support for the 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 | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/java/org/apache/coyote/ajp/AjpAprProcessor.java b/java/org/apache/coyote/ajp/AjpAprProcessor.java index 3ce901d51..2422e8cd4 100644 --- a/java/org/apache/coyote/ajp/AjpAprProcessor.java +++ b/java/org/apache/coyote/ajp/AjpAprProcessor.java @@ -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(); } -- 2.11.0