Cancel the blocking key only, no need to cancel anything else here
authorfhanik <fhanik@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 8 Jun 2007 10:52:49 +0000 (10:52 +0000)
committerfhanik <fhanik@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 8 Jun 2007 10:52:49 +0000 (10:52 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@545474 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/tomcat/util/net/NioBlockingSelector.java

index 84b45aa..ca70bde 100644 (file)
@@ -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() {