[#1614] Fix bug in SingleThreadEventExecutor which prevent scheduled tasks to get executed

The problem was that with OioSocketChannel there was always a read Task in the taskQueue and with the old logic it never tried to execute scheduled tasks if there was at least one task in the taskQueue.
This commit is contained in:
Norman Maurer 2013-07-19 11:18:41 +02:00
parent eb3283c59c
commit a4d0341ea1

View File

@ -213,18 +213,19 @@ public abstract class SingleThreadEventExecutor extends AbstractEventExecutor {
return task;
} else {
long delayNanos = delayedTask.delayNanos();
Runnable task;
Runnable task = null;
if (delayNanos > 0) {
try {
task = taskQueue.poll(delayNanos, TimeUnit.NANOSECONDS);
} catch (InterruptedException e) {
return null;
}
} else {
task = taskQueue.poll();
}
if (task == null) {
// We need to fetch the delayed tasks now as otherwise there may be a chance that
// delayed tasks are never executed if there is always one task in the taskQueue.
// This is for example true for the read task of OIO Transport
// See https://github.com/netty/netty/issues/1614
fetchFromDelayedQueue();
task = taskQueue.poll();
}