335641 Cleaned up dispatch handling to avoid key.interestOps==0 when undispatched

git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@2710 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
Greg Wilkins 2011-01-31 03:19:14 +00:00
parent acc4f230fc
commit af512e980a
3 changed files with 5 additions and 36 deletions

View File

@ -28,7 +28,7 @@ jetty-7.3.0-SNAPSHOT
+ 334229 javax-security needs to import the package javax.security.cert in its OSGi manifest + 334229 javax-security needs to import the package javax.security.cert in its OSGi manifest
+ 334311 fix buffer reuse issue in CachedExchange + 334311 fix buffer reuse issue in CachedExchange
+ 335361 Fixed 'jetty.sh check' to show current PID when JETTY_PID env. variable is set + 335361 Fixed 'jetty.sh check' to show current PID when JETTY_PID env. variable is set
+ 335641 Sweep for Windows selectKey.interestOps!=endp.interestOps for undispatched end points + 335641 Cleaned up dispatch handling to avoid key.interestOps==0 when undispatched
+ 335681 Improve ChannelEndPoint.close() to avoid spinning + 335681 Improve ChannelEndPoint.close() to avoid spinning
jetty-7.2.2.v20101205 5 December 2010 jetty-7.2.2.v20101205 5 December 2010

View File

@ -173,10 +173,12 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo
{ {
dispatch(); dispatch();
if (_dispatched && !_selectSet.getManager().isDeferringInterestedOps0()) if (_dispatched && !_selectSet.getManager().isDeferringInterestedOps0())
{
_key.interestOps(0); _key.interestOps(0);
} }
} }
} }
}
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
public void dispatch() public void dispatch()
@ -184,7 +186,9 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo
synchronized(this) synchronized(this)
{ {
if (_dispatched) if (_dispatched)
{
_redispatched=true; _redispatched=true;
}
else else
{ {
_dispatched = _manager.dispatch(_handler); _dispatched = _manager.dispatch(_handler);
@ -417,7 +421,6 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo
if(_interestOps == ops && getChannel().isOpen()) if(_interestOps == ops && getChannel().isOpen())
return; return;
} }
_selectSet.addChange(this); _selectSet.addChange(this);
_selectSet.wakeup(); _selectSet.wakeup();
@ -606,21 +609,4 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo
{ {
_maxIdleTime=timeMs; _maxIdleTime=timeMs;
} }
/* ------------------------------------------------------------ */
/**
* This looks for undispatched endpoints that have key.interestOps!=endp.interestOps
* @TODO find out the root cause of this and delete this method.
*/
public void checkWindowsBug(SelectionKey key)
{
synchronized (this)
{
if (!_dispatched && key.interestOps()!=_interestOps)
{
Log.warn("Windows NIO bug? "+key.interestOps()+"!="+_interestOps+" for "+this);
doUpdateKey();
}
}
}
} }

View File

@ -43,9 +43,6 @@ import org.eclipse.jetty.util.thread.Timeout.Task;
*/ */
public abstract class SelectorManager extends AbstractLifeCycle public abstract class SelectorManager extends AbstractLifeCycle
{ {
// TODO remove this
private final static boolean __onWindows = System.getProperty("os.name").toLowerCase().indexOf("windows")>=0;
// TODO Tune these by approx system speed. // TODO Tune these by approx system speed.
private static final int __JVMBUG_THRESHHOLD=Integer.getInteger("org.eclipse.jetty.io.nio.JVMBUG_THRESHHOLD",0).intValue(); private static final int __JVMBUG_THRESHHOLD=Integer.getInteger("org.eclipse.jetty.io.nio.JVMBUG_THRESHHOLD",0).intValue();
private static final int __MONITOR_PERIOD=Integer.getInteger("org.eclipse.jetty.io.nio.MONITOR_PERIOD",1000).intValue(); private static final int __MONITOR_PERIOD=Integer.getInteger("org.eclipse.jetty.io.nio.MONITOR_PERIOD",1000).intValue();
@ -571,20 +568,6 @@ public abstract class SelectorManager extends AbstractLifeCycle
} }
} }
}); });
// TODO find root cause and remove this
// Check for windows bug
// This looks for undispatched endpoints that have key.interestOps!=endp.interestOps
if (__onWindows)
{
for (SelectionKey key: selector.keys())
{
if (key.isValid() && key.attachment() instanceof SelectChannelEndPoint)
{
((SelectChannelEndPoint)key.attachment()).checkWindowsBug(key);
}
}
}
} }
} }
catch (CancelledKeyException e) catch (CancelledKeyException e)