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
This commit is contained in:
Greg Wilkins 2009-06-16 08:09:19 +00:00
parent 0e67706c27
commit 99f078d0ee
4 changed files with 18 additions and 14 deletions

View File

@ -19,9 +19,8 @@ public interface AsyncEndPoint extends EndPoint
/** /**
* Dispatch the endpoint to a thread to attend to it. * 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 * @return true if this endpoint can accept a dispatch. False if the

View File

@ -124,26 +124,29 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements Runnable,
_writable = true; // Once writable is in ops, only removed with dispatch. _writable = true; // Once writable is in ops, only removed with dispatch.
} }
if (!dispatch()) if (_dispatched)
updateKey(); _key.interestOps(0);
else
dispatch();
} }
} }
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
public boolean dispatch() public void dispatch()
{ {
synchronized(this) synchronized(this)
{ {
if (_dispatched) if (_dispatched)
{
_redispatched=true; _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. * Called when a dispatched thread is no longer handling the endpoint.
* The selection key operations are updated. * 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() protected boolean undispatch()
{ {

View File

@ -682,7 +682,6 @@ public class HttpConnection implements Connection
return _generator; return _generator;
} }
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
public boolean isIncluding() public boolean isIncluding()
{ {
@ -777,6 +776,7 @@ public class HttpConnection implements Connection
} }
catch (Exception e) catch (Exception e)
{ {
Log.warn(e);
throw new HttpException(HttpStatus.BAD_REQUEST_400,null,e); throw new HttpException(HttpStatus.BAD_REQUEST_400,null,e);
} }
} }

View File

@ -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(); 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 (status.equals(last))
{ {
if (same++>10) if (same++>5)
{ {
System.err.println("STALLED!!!"); System.err.println("STALLED!!!");
System.err.println(_server.getThreadPool().toString()); System.err.println(_server.getThreadPool().toString());