Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimone Bordet2015-07-08 10:48:53 +0000
committerSimone Bordet2015-07-08 10:48:53 +0000
commitf62305b5a5010b77783d5af39d364f09ace8b0e0 (patch)
treef1f7c17e79e134b5300380586bdf1b1799601b25
parent4e3b40055061d22edc013ac5f179d0eda01926ed (diff)
downloadorg.eclipse.jetty.project-f62305b5a5010b77783d5af39d364f09ace8b0e0.tar.gz
org.eclipse.jetty.project-f62305b5a5010b77783d5af39d364f09ace8b0e0.tar.xz
org.eclipse.jetty.project-f62305b5a5010b77783d5af39d364f09ace8b0e0.zip
Bug 470727 - Thread Starvation of selector wakeups.
Added comment on running non-blocking code immediately.
-rw-r--r--jetty-io/src/main/java/org/eclipse/jetty/io/SelectChannelEndPoint.java19
1 files changed, 11 insertions, 8 deletions
diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/SelectChannelEndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/SelectChannelEndPoint.java
index f15343d26f..ff05edd6c2 100644
--- a/jetty-io/src/main/java/org/eclipse/jetty/io/SelectChannelEndPoint.java
+++ b/jetty-io/src/main/java/org/eclipse/jetty/io/SelectChannelEndPoint.java
@@ -100,22 +100,25 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements ManagedSel
if (LOG.isDebugEnabled())
LOG.debug("onSelected {}->{} for {}", oldInterestOps, newInterestOps, this);
-
boolean readable = (readyOps & SelectionKey.OP_READ) != 0;
boolean writable = (readyOps & SelectionKey.OP_WRITE) != 0;
-
- // Call non blocking directly
+
+ // Run non-blocking code immediately.
+ // This producer knows that this non-blocking code is special
+ // and that it must be run in this thread and not fed to the
+ // ExecutionStrategy, which could not have any thread to run these
+ // tasks (or it may starve forever just after having run them).
if (readable && getFillInterest().isCallbackNonBlocking())
{
- getFillInterest().fillable();
- readable=false;
+ _runFillable.run();
+ readable = false;
}
if (writable && getWriteFlusher().isCallbackNonBlocking())
{
- getWriteFlusher().completeWrite();
- writable=false;
+ _runCompleteWrite.run();
+ writable = false;
}
-
+
// return task to complete the job
return readable ? (writable ? _runFillableCompleteWrite : _runFillable)
: (writable ? _runCompleteWrite : null);

Back to the top