From: fhanik Date: Mon, 8 Dec 2008 15:52:23 +0000 (+0000) Subject: implement a bit cleanup and a rough estimate on the size of a poller X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=8583fc5e9891cde0e9d6ac5b1c6e04f409afd3b6;p=tomcat7.0 implement a bit cleanup and a rough estimate on the size of a poller git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@724384 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 dd3eea8c9..aebdce1a2 100644 --- a/java/org/apache/tomcat/util/net/NioEndpoint.java +++ b/java/org/apache/tomcat/util/net/NioEndpoint.java @@ -1280,12 +1280,14 @@ public class NioEndpoint { protected CountDownLatch stopLatch = new CountDownLatch(1); - + protected volatile int keyCount = 0; public Poller() throws IOException { this.selector = Selector.open(); } + public int getKeyCount() { return keyCount; } + public Selector getSelector() { return selector;} /** @@ -1380,8 +1382,9 @@ public class NioEndpoint { //processSocket(ka.getChannel(), status, dispatch); ka.setComet(false);//to avoid a loop if (status == SocketStatus.TIMEOUT ) { - processSocket(ka.getChannel(), status, true); - return; // don't close on comet timeout + if (processSocket(ka.getChannel(), status, true)) { + return; // don't close on comet timeout + } } else { processSocket(ka.getChannel(), status, false); //don't dispatch if the lines below are cancelling the key } @@ -1430,7 +1433,8 @@ public class NioEndpoint { //do a non blocking select keyCount = selector.selectNow(); }else { - wakeupCounter.set( -1); + keyCount = selector.keys().size(); + wakeupCounter.set(-1); keyCount = selector.select(selectorTimeout); } wakeupCounter.set(0);