From: fhanik Date: Wed, 14 Sep 2011 14:39:05 +0000 (+0000) Subject: https://issues.apache.org/bugzilla/show_bug.cgi?id=51794 X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=2edafe9a0c24eac520e223e3b1df61b2686b7bfa;p=tomcat7.0 https://issues.apache.org/bugzilla/show_bug.cgi?id=51794 Fix race condition in selector potentially causing a delay in select operations git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1170647 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/tomcat/util/net/NioEndpoint.java b/java/org/apache/tomcat/util/net/NioEndpoint.java index ca8ba2d08..6a2ae9172 100644 --- a/java/org/apache/tomcat/util/net/NioEndpoint.java +++ b/java/org/apache/tomcat/util/net/NioEndpoint.java @@ -1081,13 +1081,11 @@ public class NioEndpoint extends AbstractEndpoint { } try { if ( !close ) { - if (wakeupCounter.get()>0) { + if (wakeupCounter.getAndSet(-1) > 0) { //if we are here, means we have other stuff to do //do a non blocking select keyCount = selector.selectNow(); - }else { - keyCount = selector.keys().size(); - wakeupCounter.set(-1); + } else { keyCount = selector.select(selectorTimeout); } wakeupCounter.set(0);