Make write operation cancellation while it's in progress
.. which should be useful when writing a large buffer/file
This commit is contained in:
parent
2d7c6f8ee1
commit
7a1550631d
@ -18,6 +18,7 @@ package io.netty.channel;
|
|||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.buffer.ByteBufAllocator;
|
import io.netty.buffer.ByteBufAllocator;
|
||||||
import io.netty.buffer.ByteBufHolder;
|
import io.netty.buffer.ByteBufHolder;
|
||||||
|
import io.netty.buffer.ByteBufUtil;
|
||||||
import io.netty.util.DefaultAttributeMap;
|
import io.netty.util.DefaultAttributeMap;
|
||||||
import io.netty.util.internal.PlatformDependent;
|
import io.netty.util.internal.PlatformDependent;
|
||||||
import io.netty.util.internal.logging.InternalLogger;
|
import io.netty.util.internal.logging.InternalLogger;
|
||||||
@ -696,9 +697,13 @@ public abstract class AbstractChannel extends DefaultAttributeMap implements Cha
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure the promise has not been cancelled yet.
|
// Make sure the promise has not been cancelled.
|
||||||
if (!promise.setUncancellable()) {
|
if (promise.isCancelled()) {
|
||||||
messages.releaseAllAndRecycle();
|
// If cancelled, release all unwritten messages and recycle.
|
||||||
|
for (int i = messageIndex; i < messageCount; i ++) {
|
||||||
|
ByteBufUtil.release(messages.get(i));
|
||||||
|
}
|
||||||
|
messages.recycle();
|
||||||
if (!outboundBuffer.next()) {
|
if (!outboundBuffer.next()) {
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user