From 968063c1ab64e9d19045c14850d35b137c569894 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Thu, 19 Feb 2015 18:13:31 +1100 Subject: [PATCH] Fixed AsyncIO double dispatch --- .../org/eclipse/jetty/http2/server/HttpInputOverHTTP2.java | 2 +- .../src/main/java/org/eclipse/jetty/io/FillInterest.java | 4 +++- .../src/main/java/org/eclipse/jetty/server/HttpChannel.java | 2 +- .../java/org/eclipse/jetty/server/HttpChannelState.java | 4 ++-- .../java/org/eclipse/jetty/server/HttpInputOverHTTP.java | 2 +- .../org/eclipse/jetty/util/thread/QueuedThreadPool.java | 6 ++++++ 6 files changed, 14 insertions(+), 6 deletions(-) diff --git a/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HttpInputOverHTTP2.java b/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HttpInputOverHTTP2.java index 99e839ab6ba..2f137250392 100644 --- a/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HttpInputOverHTTP2.java +++ b/jetty-http2/http2-server/src/main/java/org/eclipse/jetty/http2/server/HttpInputOverHTTP2.java @@ -33,6 +33,6 @@ public class HttpInputOverHTTP2 extends HttpInput @Override protected void onReadPossible() { - _httpChannelState.onReadPossible(); + _httpChannelState.onReadPossible(true); } } diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/FillInterest.java b/jetty-io/src/main/java/org/eclipse/jetty/io/FillInterest.java index de52bbd7cc2..e3bc03eccaf 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/FillInterest.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/FillInterest.java @@ -60,6 +60,8 @@ public abstract class FillInterest } try { + if (LOG.isDebugEnabled()) + LOG.debug("{} register {}",this,callback); needsFillInterest(); } catch (Throwable e) @@ -78,7 +80,7 @@ public abstract class FillInterest LOG.debug("{} fillable {}",this,callback); if (callback != null && _interested.compareAndSet(callback, null)) callback.succeeded(); - else + else if (LOG.isDebugEnabled()) LOG.debug("{} lost race {}",this,callback); } diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannel.java b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannel.java index 4282d54c53c..a629fb7d400 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannel.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannel.java @@ -107,7 +107,7 @@ public class HttpChannel implements Runnable, HttpOutput.Interceptor @Override protected void onReadPossible() { - getState().onReadPossible(); + getState().onReadPossible(true); } }; } diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannelState.java b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannelState.java index 7fdfe9c304e..e61b7c4a3db 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannelState.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpChannelState.java @@ -716,7 +716,7 @@ public class HttpChannelState _channel.getRequest().setAttribute(name,attribute); } - public void onReadPossible() + public void onReadPossible(boolean execute) { boolean handle=false; @@ -730,7 +730,7 @@ public class HttpChannelState } } - if (handle) + if (execute && handle) // TODO, do we need to execute or just run? _channel.execute(_channel); } diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpInputOverHTTP.java b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpInputOverHTTP.java index c6c1d35352d..03860b4f791 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpInputOverHTTP.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpInputOverHTTP.java @@ -51,6 +51,6 @@ public class HttpInputOverHTTP extends HttpInput @Override protected void onReadPossible() { - _httpConnection.getHttpChannel().getState().onReadPossible(); + _httpConnection.getHttpChannel().getState().onReadPossible(false); // Will be handled by async callback } } diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/thread/QueuedThreadPool.java b/jetty-util/src/main/java/org/eclipse/jetty/util/thread/QueuedThreadPool.java index 5a71f7b34e6..425b7c5fb73 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/thread/QueuedThreadPool.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/thread/QueuedThreadPool.java @@ -356,6 +356,8 @@ public class QueuedThreadPool extends AbstractLifeCycle implements SizedThreadPo @Override public void execute(Runnable job) { + if (LOG.isDebugEnabled()) + LOG.debug("queue {}",job); if (!isRunning() || !_jobs.offer(job)) { LOG.warn("{} rejected {}", this, job); @@ -552,7 +554,11 @@ public class QueuedThreadPool extends AbstractLifeCycle implements SizedThreadPo // Job loop while (job != null && isRunning()) { + if (LOG.isDebugEnabled()) + LOG.debug("run {}",job); runJob(job); + if (LOG.isDebugEnabled()) + LOG.debug("ran {}",job); if (Thread.interrupted()) { ignore=true;