Skip to content

Commit

Permalink
Flush task should not flush messages that were written since last flu…
Browse files Browse the repository at this point in the history
…sh 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.
  • Loading branch information
normanmaurer committed Mar 2, 2018
1 parent 12ccd40 commit 0a8e1aa
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ public abstract class AbstractEpollStreamChannel extends AbstractEpollChannel im
private final Runnable flushTask = new Runnable() {
@Override
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ public abstract class AbstractKQueueStreamChannel extends AbstractKQueueChannel
private final Runnable flushTask = new Runnable() {
@Override
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();
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ public abstract class AbstractNioByteChannel extends AbstractNioChannel {
private final Runnable flushTask = new Runnable() {
@Override
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();
}
};

Expand Down

0 comments on commit 0a8e1aa

Please sign in to comment.