335641 Sweep for Windows selectKey.interestOps!=endp.interestOps for undispatched end points

This is a temporary fix until we get to the root of the problem

git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@2702 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
Greg Wilkins 2011-01-28 01:12:48 +00:00
parent f41fe5d7b4
commit 4b8b8b3ba0
3 changed files with 44 additions and 20 deletions

View File

@ -1,6 +1,7 @@
jetty-7.3.1-SNAPSHOT jetty-7.3.1-SNAPSHOT
+ 331803 Update XML configuration files to use proper arguments for startup command in examples + 331803 Update XML configuration files to use proper arguments for startup command in examples
+ 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
jetty-7.3.0.v20112401 24 January 2011 jetty-7.3.0.v20112401 24 January 2011
+ JETTY-1259 NullPointerException in JDBCSessionIdManager when invalidating session (further update) + JETTY-1259 NullPointerException in JDBCSessionIdManager when invalidating session (further update)

View File

@ -146,7 +146,8 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo
this.notifyAll(); this.notifyAll();
// we are not interested in further selecting // we are not interested in further selecting
_key.interestOps(0); if (_dispatched)
_key.interestOps(0);
return; return;
} }
@ -158,7 +159,6 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo
return; return;
} }
// Remove writeable op // Remove writeable op
if ((_key.readyOps() & SelectionKey.OP_WRITE) == SelectionKey.OP_WRITE && (_key.interestOps() & SelectionKey.OP_WRITE) == SelectionKey.OP_WRITE) if ((_key.readyOps() & SelectionKey.OP_WRITE) == SelectionKey.OP_WRITE && (_key.interestOps() & SelectionKey.OP_WRITE) == SelectionKey.OP_WRITE)
{ {
@ -168,18 +168,12 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo
_writable = true; // Once writable is in ops, only removed with dispatch. _writable = true; // Once writable is in ops, only removed with dispatch.
} }
if (_selectSet.getManager().isDeferringInterestedOps0()) // Dispatch if we are not already
if (!_dispatched)
{ {
if (_dispatched) dispatch();
if (_dispatched && !_selectSet.getManager().isDeferringInterestedOps0())
_key.interestOps(0); _key.interestOps(0);
else
dispatch();
}
else
{
_key.interestOps(0);
if (!_dispatched)
dispatch();
} }
} }
} }
@ -298,6 +292,7 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo
{ {
synchronized (this) synchronized (this)
{ {
// Ready if not dispatched and not suspended
return !(_dispatched || getConnection().isSuspended()); return !(_dispatched || getConnection().isSuspended());
} }
} }
@ -612,6 +607,20 @@ 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

@ -23,8 +23,6 @@ import java.nio.channels.SocketChannel;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import org.eclipse.jetty.io.ConnectedEndPoint; import org.eclipse.jetty.io.ConnectedEndPoint;
import org.eclipse.jetty.io.Connection; import org.eclipse.jetty.io.Connection;
@ -45,6 +43,9 @@ 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();
@ -59,7 +60,7 @@ public abstract class SelectorManager extends AbstractLifeCycle
private SelectSet[] _selectSet; private SelectSet[] _selectSet;
private int _selectSets=1; private int _selectSets=1;
private volatile int _set; private volatile int _set;
private boolean _deferringInterestedOps0; private boolean _deferringInterestedOps0=true;
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
/** /**
@ -570,6 +571,20 @@ 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)
@ -855,7 +870,6 @@ public abstract class SelectorManager extends AbstractLifeCycle
} }
} }
} }
} }
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
@ -879,9 +893,9 @@ public abstract class SelectorManager extends AbstractLifeCycle
} }
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */
public void setDeferringInterestedOps0(boolean defferringInterestedOps0) public void setDeferringInterestedOps0(boolean deferringInterestedOps0)
{ {
_deferringInterestedOps0 = defferringInterestedOps0; _deferringInterestedOps0 = deferringInterestedOps0;
} }
} }