Author: markt Date: Tue Sep 10 12:18:00 2013 New Revision: 1521457 URL: http://svn.apache.org/r1521457 Log: Fix failing org.apache.coyote.ajp.TestAbstractAjpProcessor unit test. Handle EAGAIN result from non-blocking read.
Modified: tomcat/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java tomcat/trunk/java/org/apache/coyote/ajp/LocalStrings.properties Modified: tomcat/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java?rev=1521457&r1=1521456&r2=1521457&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java (original) +++ tomcat/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java Tue Sep 10 12:18:00 2013 @@ -17,6 +17,7 @@ package org.apache.coyote.ajp; import java.io.IOException; +import java.net.SocketTimeoutException; import java.nio.ByteBuffer; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock; @@ -201,6 +202,21 @@ public class AjpAprProcessor extends Abs if (nRead == 0) { // Must be a non-blocking read return false; + } else if (-nRead == Status.EAGAIN) { + return false; + } else if ((-nRead) == Status.ETIMEDOUT || (-nRead) == Status.TIMEUP) { + if (block) { + throw new SocketTimeoutException( + sm.getString("ajpprocessor.readtimeout")); + } else { + // Attempting to read from the socket when the poller + // has not signalled that there is data to read appears + // to behave like a blocking read with a short timeout + // on OSX rather than like a non-blocking read. If no + // data is read, treat the resulting timeout like a + // non-blocking read that returned no data. + return false; + } } else if (nRead > 0) { inputBuffer.limit(inputBuffer.limit() + nRead); nextReadBlocks = true; Modified: tomcat/trunk/java/org/apache/coyote/ajp/LocalStrings.properties URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/ajp/LocalStrings.properties?rev=1521457&r1=1521456&r2=1521457&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/coyote/ajp/LocalStrings.properties (original) +++ tomcat/trunk/java/org/apache/coyote/ajp/LocalStrings.properties Tue Sep 10 12:18:00 2013 @@ -20,6 +20,7 @@ ajpprocessor.failedread=Socket read fail ajpprocessor.failedsend=Failed to send AJP message ajpprocessor.header.error=Header message parsing failed ajpprocessor.header.tooLong=Header message of length [{0}] received but the packetSize is only [{1}] +ajpprocessor.readtimeout=Timeout attempting to read data from the socket ajpprocessor.request.prepare=Error preparing request ajpprocessor.request.process=Error processing request ajpprocessor.certs.fail=Certificate conversion failed --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org