From 2edafe9a0c24eac520e223e3b1df61b2686b7bfa Mon Sep 17 00:00:00 2001 From: fhanik Date: Wed, 14 Sep 2011 14:39:05 +0000 Subject: [PATCH] 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 --- java/org/apache/tomcat/util/net/NioEndpoint.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) 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); -- 2.11.0