335641 added a sweep to check for error

git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@2728 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
Greg Wilkins 2011-02-02 20:09:47 +00:00
parent 210fc406b8
commit 0b41841e0a
4 changed files with 37 additions and 9 deletions

View File

@ -51,6 +51,7 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo
private boolean _writeBlocked;
private boolean _open;
private volatile long _idleTimestamp;
private boolean _changing=false;
/* ------------------------------------------------------------ */
public SelectChannelEndPoint(SocketChannel channel, SelectSet selectSet, SelectionKey key, int maxIdleTime)
@ -423,6 +424,7 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo
if(_interestOps == ops && getChannel().isOpen())
return;
_changing=true;
}
_selectSet.addChange(this);
_selectSet.wakeup();
@ -436,6 +438,7 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo
{
synchronized (this)
{
_changing=false;
if (getChannel().isOpen())
{
if (_interestOps>0)
@ -612,4 +615,22 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo
{
_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 checkKey(SelectionKey key)
{
synchronized (this)
{
if (!_changing && !_dispatched && key.interestOps()!=_interestOps)
{
Log.warn("NIO InterestOps mismatch "+key.interestOps()+"!="+_interestOps+" for "+this);
updateKey();
}
}
}
}

View File

@ -22,7 +22,6 @@ import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
@ -562,6 +561,16 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
}
}
});
// TODO find root cause and remove this
// This looks for undispatched endpoints that have key.interestOps!=endp.interestOps
for (SelectionKey key: selector.keys())
{
if (key.isValid() && key.attachment() instanceof SelectChannelEndPoint)
{
((SelectChannelEndPoint)key.attachment()).checkKey(key);
}
}
}
}
catch (CancelledKeyException e)
@ -881,7 +890,8 @@ public abstract class SelectorManager extends AbstractLifeCycle implements Dumpa
}
AggregateLifeCycle.dump(out,indent,dump);
}
/* ------------------------------------------------------------ */
public void dumpKeyState(List<Object> dumpto)
{
Selector selector=_selector;

View File

@ -152,6 +152,7 @@ public class StressTest
{
final int id=i;
final String name = "T"+i;
Thread.sleep(_random.nextInt(100));
threads[i]=new Thread()
{
@Override
@ -305,8 +306,8 @@ public class StressTest
{
_loops[thread].set(i);
doPaths(thread,name+"-"+i,persistent);
Thread.sleep(1+_random.nextInt(10)*_random.nextInt(10));
Thread.sleep(10);
Thread.sleep(1+_random.nextInt(20)*_random.nextInt(20));
Thread.sleep(20);
}
_loops[thread].set(loops);
}

View File

@ -20,7 +20,6 @@ import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.Vector;
@ -145,18 +144,15 @@ public class Classpath {
private static class Loader extends URLClassLoader
{
String name;
Loader(URL[] urls, ClassLoader parent)
{
super(urls, parent);
name = "StartLoader"+Arrays.asList(urls);
}
@Override
public String toString()
{
return name;
return "startJarLoader@"+Long.toHexString(hashCode());
}
}