Author: markt
Date: Sat Apr 16 23:41:32 2011
New Revision: 1094088
URL: http://svn.apache.org/viewvc?rev=1094088&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=50158
Ensure the asynchronous requests never timeout if the timeout is set to zero or
less.
Based on a patch provided by Chris.
Modified:
tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java
tomcat/trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java
tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java
tomcat/trunk/java/org/apache/tomcat/util/net/SocketProperties.java
tomcat/trunk/webapps/docs/changelog.xml
Modified: tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java?rev=1094088&r1=1094087&r2=1094088&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java Sat Apr 16
23:41:32 2011
@@ -1024,7 +1024,8 @@ public class AprEndpoint extends Abstrac
SocketWrapper<Long> socket = sockets.next();
if (socket.async) {
long access = socket.getLastAccess();
- if ((now-access)>socket.getTimeout()) {
+ if (socket.getTimeout() > 0 &&
+ (now-access)>socket.getTimeout()) {
processSocketAsync(socket,SocketStatus.TIMEOUT);
}
}
Modified: tomcat/trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java?rev=1094088&r1=1094087&r2=1094088&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java Sat Apr 16
23:41:32 2011
@@ -150,7 +150,8 @@ public class JIoEndpoint extends Abstrac
while (sockets.hasNext()) {
SocketWrapper<Socket> socket = sockets.next();
long access = socket.getLastAccess();
- if ((now-access)>socket.getTimeout()) {
+ if (socket.getTimeout() > 0 &&
+ (now-access)>socket.getTimeout()) {
processSocketAsync(socket,SocketStatus.TIMEOUT);
}
}
Modified: tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java?rev=1094088&r1=1094087&r2=1094088&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/NioEndpoint.java Sat Apr 16
23:41:32 2011
@@ -1344,13 +1344,16 @@ public class NioEndpoint extends Abstrac
nextExpiration = (nextTime <
nextExpiration)?nextTime:nextExpiration;
}
} else if (ka.isAsync() || ka.getComet()) {
- long delta = now - ka.getLastAccess();
- long timeout = (ka.getTimeout()==-1)?((long)
socketProperties.getSoTimeout()):(ka.getTimeout());
- boolean isTimedout = delta > timeout;
- if (isTimedout) {
- // Prevent subsequent timeouts if the timeout
event takes a while to process
- ka.access(Long.MAX_VALUE);
- processSocket(ka.getChannel(),
SocketStatus.TIMEOUT, true);
+ // Async requests with a timeout of 0 or less never
timeout
+ if (!ka.isAsync() || ka.getTimeout() > 0) {
+ long delta = now - ka.getLastAccess();
+ long timeout = (ka.getTimeout()==-1)?((long)
socketProperties.getSoTimeout()):(ka.getTimeout());
+ boolean isTimedout = delta > timeout;
+ if (isTimedout) {
+ // Prevent subsequent timeouts if the timeout
event takes a while to process
+ ka.access(Long.MAX_VALUE);
+ processSocket(ka.getChannel(),
SocketStatus.TIMEOUT, true);
+ }
}
}//end if
}catch ( CancelledKeyException ckx ) {
Modified: tomcat/trunk/java/org/apache/tomcat/util/net/SocketProperties.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/SocketProperties.java?rev=1094088&r1=1094087&r2=1094088&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/SocketProperties.java
(original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/SocketProperties.java Sat Apr
16 23:41:32 2011
@@ -173,8 +173,8 @@ public class SocketProperties {
protected Integer performanceBandwidth = null;
/**
- * The minimum frequency of the timeout interval to avoid the
- * poller going boinkers during high traffic
+ * The minimum frequency of the timeout interval to avoid excess load from
+ * the poller during high traffic
*/
protected long timeoutInterval = 1000;
Modified: tomcat/trunk/webapps/docs/changelog.xml
URL:
http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1094088&r1=1094087&r2=1094088&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Sat Apr 16 23:41:32 2011
@@ -82,6 +82,11 @@
<bug>50957</bug>: Fix regression in HTTP BIO connector that triggered
errors when processing pipe-lined requests. (markt)
</fix>
+ <fix>
+ <bug>50158</bug>: Ensure the asynchronous requests never timeout if the
+ timeout is set to zero or less. Based on a patch provided by Chris.
+ (markt)
+ </fix>
</changelog>
</subsection>
<subsection name="Jasper">
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]