Fix a bug where ChannelOutboundBuffer.addFlush() is called multiple times

This commit is contained in:
Trustin Lee 2013-07-12 20:01:38 +09:00
parent e2fcb06d9a
commit 529d904d29

View File

@ -595,7 +595,10 @@ public abstract class AbstractChannel extends DefaultAttributeMap implements Cha
@Override
public void flush() {
outboundBuffer.addFlush();
flush0();
}
private void flush0() {
if (!inFlushNow) { // Avoid re-entrance
// Flush immediately only when there's no pending flush.
// If there's a pending flush operation, event loop will call flushNow() later,
@ -609,7 +612,7 @@ public abstract class AbstractChannel extends DefaultAttributeMap implements Cha
eventLoop().execute(new Runnable() {
@Override
public void run() {
flush();
flush0();
}
});
}