Flush task should not flush messages that were written since last flush attempt.

Motivation:

The flush task is currently using flush() which will have the affect of have the flush traverse the whole ChannelPipeline and also flush messages that were written since we gave up flushing. This is not really correct as we should only continue to flush messages that were flushed at the point in time when the flush task was submitted for execution if the user not explicit call flush() by him/herself.

Modification:

Call *Unsafe.flush0() via the flush task which will only continue flushing messages that were marked as flushed before.

Result:

More correct behaviour when the flush task is used.
This commit is contained in:
Norman Maurer 2018-02-22 07:42:49 +01:00 committed by Norman Maurer
parent 12ccd40c5a
commit 0a8e1aaf19
3 changed files with 9 additions and 3 deletions

View File

@ -73,7 +73,9 @@ public abstract class AbstractEpollStreamChannel extends AbstractEpollChannel im
private final Runnable flushTask = new Runnable() { private final Runnable flushTask = new Runnable() {
@Override @Override
public void run() { public void run() {
flush(); // Calling flush0 directly to ensure we not try to flush messages that were added via write(...) in the
// meantime.
((AbstractEpollUnsafe) unsafe()).flush0();
} }
}; };
private Queue<SpliceInTask> spliceQueue; private Queue<SpliceInTask> spliceQueue;

View File

@ -59,7 +59,9 @@ public abstract class AbstractKQueueStreamChannel extends AbstractKQueueChannel
private final Runnable flushTask = new Runnable() { private final Runnable flushTask = new Runnable() {
@Override @Override
public void run() { public void run() {
flush(); // Calling flush0 directly to ensure we not try to flush messages that were added via write(...) in the
// meantime.
((AbstractKQueueUnsafe) unsafe()).flush0();
} }
}; };

View File

@ -49,7 +49,9 @@ public abstract class AbstractNioByteChannel extends AbstractNioChannel {
private final Runnable flushTask = new Runnable() { private final Runnable flushTask = new Runnable() {
@Override @Override
public void run() { public void run() {
flush(); // Calling flush0 directly to ensure we not try to flush messages that were added via write(...) in the
// meantime.
((AbstractNioUnsafe) unsafe()).flush0();
} }
}; };