Don't rely on the return value fo Selector.select(..) as it is buggy and so can cause 100% cpu usage. See #535

This commit is contained in:
norman 2012-08-24 08:59:39 +02:00
parent 573fbfa518
commit 5c6e3fe6ba

View File

@ -242,7 +242,7 @@ class NioClientSocketPipelineSink extends AbstractNioChannelSink {
wakenUp.set(false);
try {
int selectedKeyCount = selector.select(10);
SelectorUtil.select(selector);
// 'wakenUp.compareAndSet(false, true)' is always evaluated
// before calling 'selector.wakeup()' to reduce the wake-up
@ -277,10 +277,7 @@ class NioClientSocketPipelineSink extends AbstractNioChannelSink {
}
processRegisterTaskQueue();
if (selectedKeyCount > 0) {
processSelectedKeys(selector.selectedKeys());
}
processSelectedKeys(selector.selectedKeys());
// Handle connection timeout every 10 milliseconds approximately.
long currentTimeNanos = System.nanoTime();