From 99f078d0eeada148182bc0483f8bdedf44fb19f0 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Tue, 16 Jun 2009 08:09:19 +0000 Subject: [PATCH] cleanup of dispatch code git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@406 7e9141cc-0065-0410-87d8-b60c137991c4 --- .../org/eclipse/jetty/io/AsyncEndPoint.java | 3 +-- .../jetty/io/nio/SelectChannelEndPoint.java | 25 +++++++++++-------- .../eclipse/jetty/server/HttpConnection.java | 2 +- .../org/eclipse/jetty/server/StressTest.java | 2 +- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/AsyncEndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/AsyncEndPoint.java index 82da8133546..75b92d00412 100644 --- a/jetty-io/src/main/java/org/eclipse/jetty/io/AsyncEndPoint.java +++ b/jetty-io/src/main/java/org/eclipse/jetty/io/AsyncEndPoint.java @@ -19,9 +19,8 @@ public interface AsyncEndPoint extends EndPoint /** * Dispatch the endpoint to a thread to attend to it. * - * @return True If the dispatched succeeded */ - public boolean dispatch(); + public void dispatch(); /** * @return true if this endpoint can accept a dispatch. False if the 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 1539b020f5d..d616ec0bb1f 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 @@ -124,26 +124,29 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements Runnable, _writable = true; // Once writable is in ops, only removed with dispatch. } - if (!dispatch()) - updateKey(); + if (_dispatched) + _key.interestOps(0); + else + dispatch(); } } /* ------------------------------------------------------------ */ - public boolean dispatch() + public void dispatch() { synchronized(this) { if (_dispatched) - { _redispatched=true; - return true; + else + { + _dispatched = _manager.dispatch((Runnable)this); + if(!_dispatched) + { + Log.warn("Dispatched Failed!"); + updateKey(); + } } - - _dispatched = _manager.dispatch((Runnable)this); - if(!_dispatched) - Log.warn("Dispatched Failed!"); - return _dispatched; } } @@ -151,6 +154,8 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements Runnable, /** * Called when a dispatched thread is no longer handling the endpoint. * The selection key operations are updated. + * @return If false is returned, the endpoint has been redispatched and + * thread must keep handling the endpoint. */ protected boolean undispatch() { diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnection.java b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnection.java index 111306c98f2..6885a05dc8a 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnection.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnection.java @@ -681,7 +681,6 @@ public class HttpConnection implements Connection { return _generator; } - /* ------------------------------------------------------------ */ public boolean isIncluding() @@ -777,6 +776,7 @@ public class HttpConnection implements Connection } catch (Exception e) { + Log.warn(e); throw new HttpException(HttpStatus.BAD_REQUEST_400,null,e); } } diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/StressTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/StressTest.java index 763ef50c050..48dd031638e 100644 --- a/jetty-server/src/test/java/org/eclipse/jetty/server/StressTest.java +++ b/jetty-server/src/test/java/org/eclipse/jetty/server/StressTest.java @@ -303,7 +303,7 @@ public class StressTest extends TestCase String status = "min/ave/max/target="+min+"/"+(total/threads)+"/"+max+"/"+loops+" errors/finished/loops="+errors+"/"+finished+"/"+threads+" idle/threads="+(_threads.getIdleThreads())+"/"+_threads.getThreads(); if (status.equals(last)) { - if (same++>10) + if (same++>5) { System.err.println("STALLED!!!"); System.err.println(_server.getThreadPool().toString());