From b21b873d56fe5430930295eaa1c100b4bb4726e2 Mon Sep 17 00:00:00 2001 From: fhanik Date: Fri, 1 Jun 2007 18:55:10 +0000 Subject: [PATCH] added cleanup code git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@543576 13f79535-47bb-0310-9956-ffa450edef68 --- .../tomcat/util/net/NioBlockingSelector.java | 26 +++++++++++++--------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/java/org/apache/tomcat/util/net/NioBlockingSelector.java b/java/org/apache/tomcat/util/net/NioBlockingSelector.java index 71b8ac56e..5b06b6739 100644 --- a/java/org/apache/tomcat/util/net/NioBlockingSelector.java +++ b/java/org/apache/tomcat/util/net/NioBlockingSelector.java @@ -20,20 +20,20 @@ import java.io.EOFException; import java.io.IOException; import java.net.SocketTimeoutException; import java.nio.ByteBuffer; +import java.nio.channels.CancelledKeyException; +import java.nio.channels.ClosedChannelException; import java.nio.channels.SelectionKey; -import java.util.concurrent.TimeUnit; - -import org.apache.tomcat.util.net.NioEndpoint.KeyAttachment; -import org.apache.tomcat.util.MutableInteger; import java.nio.channels.Selector; +import java.nio.channels.SocketChannel; +import java.util.Iterator; import java.util.concurrent.ConcurrentLinkedQueue; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + import org.apache.juli.logging.Log; import org.apache.juli.logging.LogFactory; -import java.util.Iterator; -import java.nio.channels.SocketChannel; -import java.nio.channels.ClosedChannelException; -import java.nio.channels.CancelledKeyException; -import java.util.concurrent.CountDownLatch; +import org.apache.tomcat.util.MutableInteger; +import org.apache.tomcat.util.net.NioEndpoint.KeyAttachment; public class NioBlockingSelector { @@ -61,6 +61,7 @@ public class NioBlockingSelector { if (poller!=null) { poller.disable(); poller.interrupt(); + poller = null; } } @@ -214,7 +215,12 @@ public class NioBlockingSelector { sk.interestOps(sk.interestOps() | ops); } }catch (ClosedChannelException cx) { - if (sk!=null) sk.cancel(); + if (sk!=null) { + sk.cancel(); + sk.attach(null); + if (SelectionKey.OP_WRITE==(ops&SelectionKey.OP_WRITE)) countDown(key.getWriteLatch()); + if (SelectionKey.OP_READ==(ops&SelectionKey.OP_READ))countDown(key.getReadLatch()); + } } } }; -- 2.11.0