From c034de3b5b09f72a720eb9bf6b84a80400b7b6ef Mon Sep 17 00:00:00 2001 From: fhanik Date: Fri, 8 Jun 2007 10:52:49 +0000 Subject: [PATCH] Cancel the blocking key only, no need to cancel anything else here git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@545474 13f79535-47bb-0310-9956-ffa450edef68 --- .../tomcat/util/net/NioBlockingSelector.java | 23 ++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/java/org/apache/tomcat/util/net/NioBlockingSelector.java b/java/org/apache/tomcat/util/net/NioBlockingSelector.java index 84b45aaf3..ca70bdeb2 100644 --- a/java/org/apache/tomcat/util/net/NioBlockingSelector.java +++ b/java/org/apache/tomcat/util/net/NioBlockingSelector.java @@ -122,7 +122,7 @@ public class NioBlockingSelector { } finally { poller.remove(att,SelectionKey.OP_WRITE); if (timedout && key != null) { - cancelKey(socket, key); + poller.cancelKey(socket, key); } } return written; @@ -182,26 +182,29 @@ public class NioBlockingSelector { } finally { poller.remove(att,SelectionKey.OP_READ); if (timedout && key != null) { - cancelKey(socket,key); + poller.cancelKey(socket,key); } } return read; } - private static void cancelKey(final NioChannel socket, final SelectionKey key) { - socket.getPoller().addEvent( - new Runnable() { - public void run() { - socket.getPoller().cancelledKey(key,SocketStatus.ERROR,false); - } - }); - } protected class BlockPoller extends Thread { protected boolean run = true; protected Selector selector = null; protected ConcurrentLinkedQueue events = new ConcurrentLinkedQueue(); public void disable() { run = false; selector.wakeup();} + + public void cancelKey(final NioChannel socket, final SelectionKey key) { + Runnable r = new Runnable() { + public void run() { + key.cancel(); + } + }; + events.offer(r); + selector.wakeup(); + } + public void add(final KeyAttachment key, final int ops) { Runnable r = new Runnable() { -- 2.11.0