From f70ed3ac2188d5e35a917b33f83af7536742777b Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Fri, 18 Nov 2011 09:19:52 +1100 Subject: [PATCH] prevent spin by write blocked from non dispatched thread --- .../jetty/io/nio/SelectChannelEndPoint.java | 2 ++ .../eclipse/jetty/io/nio/SelectorManager.java | 21 ++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java index 2a2e0dac18b..bedc36ef842 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java @@ -162,6 +162,8 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo // we are not interested in further selecting _key.interestOps(0); + if (!_dispatched) + updateKey(); return; } diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectorManager.java b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectorManager.java index 21823c8297b..8c6db52fb60 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectorManager.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectorManager.java @@ -444,7 +444,7 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa // Stopped concurrently ? if (selector == null) return; - + // Make any key changes required Object change; int changes=_changes.size(); @@ -585,15 +585,6 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa // Log and dump some status _paused=true; LOG.warn("Selector {} is too busy, pausing!",this); - final SelectSet set = this; - SelectorManager.this.dispatch( - new Runnable(){ - public void run() - { - System.err.println(set+":\n"+set.dump()); - } - public String toString() {return "Dump-"+super.toString();} - }); } } } @@ -991,6 +982,16 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa dumpto.add(key.attachment()+" - - "); } } + + /* ------------------------------------------------------------ */ + public String toString() + { + String s=super.toString()+" "+SelectorManager.this.getState(); + Selector selector=_selector; + if (selector!=null && selector.isOpen()) + s+=",k="+selector.keys().size()+",s="+selector.selectedKeys().size(); + return s; + } } /* ------------------------------------------------------------ */