I take back my -1
looking at the javadoc, it defines -1 as infinite.

So your commit is correct, but requires an addition

-att.awaitReadLatch(readTimeout,TimeUnit.MILLISECONDS);

+if (readTimeout<0) {
+  att.awaitReadLatch(Long.MAX_VALUE,TimeUnit.MILLISECONDS);
+} else {
+  att.awaitReadLatch(readTimeout,TimeUnit.MILLISECONDS);
+}


Filip



On 5/16/2011 3:38 PM, Mark Thomas wrote:
On 16/05/2011 16:24, Filip Hanik - Dev Lists wrote:
-1 for this change. 0 means infinite (no timeout)

http://download.oracle.com/javase/6/docs/api/java/net/Socket.html#setSoTimeout%28int%29
The problem is that readTimeout is also used in line 169:
att.awaitReadLatch(readTimeout,TimeUnit.MILLISECONDS);

and in that case the timeout is not infinite, it is immediate (Rainer
checked the JRE source) which triggers a tight CPU burning loop.

Any suggestions for a better solution? How about changing a value of 0
to -1 at the start of the method?

Mark

Filip

On 5/16/2011 1:31 AM, ma...@apache.org wrote:
Author: markt
Date: Mon May 16 07:31:23 2011
New Revision: 1103633

URL: http://svn.apache.org/viewvc?rev=1103633&view=rev
Log:
Prevent infinite loop when readTimeout = 0

Modified:

tomcat/trunk/java/org/apache/tomcat/util/net/NioBlockingSelector.java

Modified:
tomcat/trunk/java/org/apache/tomcat/util/net/NioBlockingSelector.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/NioBlockingSelector.java?rev=1103633&r1=1103632&r2=1103633&view=diff

==============================================================================

---
tomcat/trunk/java/org/apache/tomcat/util/net/NioBlockingSelector.java
(original)
+++
tomcat/trunk/java/org/apache/tomcat/util/net/NioBlockingSelector.java
Mon May 16 07:31:23 2011
@@ -178,7 +178,7 @@ public class NioBlockingSelector {
                       keycount = 1;
                       att.resetReadLatch();
                   }
-                if (readTimeout>   0&&   (keycount == 0))
+                if (readTimeout>= 0&&   (keycount == 0))
                       timedout = (System.currentTimeMillis() - time)>=
readTimeout;
               } //while
               if (timedout)



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



-----
No virus found in this message.
Checked by AVG - www.avg.com
Version: 10.0.1321 / Virus Database: 1500/3640 - Release Date: 05/15/11



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



-----
No virus found in this message.
Checked by AVG - www.avg.com
Version: 10.0.1321 / Virus Database: 1500/3641 - Release Date: 05/16/11




---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to