Move marking ChannelPromise for writes uncancellable to addFlush for keep things simple
This commit is contained in:
parent
31c24bc981
commit
b49490e239
@ -174,6 +174,18 @@ public final class ChannelOutboundBuffer {
|
||||
|
||||
void addFlush() {
|
||||
unflushed = tail;
|
||||
|
||||
final int mask = buffer.length - 1;
|
||||
int i = flushed;
|
||||
while (i != unflushed && buffer[i].msg != null) {
|
||||
Entry entry = buffer[i];
|
||||
if (!entry.promise.setUncancellable()) {
|
||||
// Was cancelled so make sure we free up memory and notify about the freed bytes
|
||||
int pending = entry.cancel();
|
||||
decrementPendingOutboundBytes(pending);
|
||||
}
|
||||
i = i + 1 & mask;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -255,12 +267,6 @@ public final class ChannelOutboundBuffer {
|
||||
} else {
|
||||
// TODO: Think of a smart way to handle ByteBufHolder messages
|
||||
Entry entry = buffer[flushed];
|
||||
if (!entry.cancelled && !entry.promise.setUncancellable()) {
|
||||
// Was cancelled so make sure we free up memory and notify about the freed bytes
|
||||
int pending = entry.cancel();
|
||||
decrementPendingOutboundBytes(pending);
|
||||
}
|
||||
|
||||
Object msg = entry.msg;
|
||||
if (threadLocalDirectBufferSize <= 0 || !preferDirect) {
|
||||
return msg;
|
||||
@ -400,11 +406,6 @@ public final class ChannelOutboundBuffer {
|
||||
Entry entry = buffer[i];
|
||||
|
||||
if (!entry.cancelled) {
|
||||
if (!entry.promise.setUncancellable()) {
|
||||
// Was cancelled so make sure we free up memory and notify about the freed bytes
|
||||
int pending = entry.cancel();
|
||||
decrementPendingOutboundBytes(pending);
|
||||
} else {
|
||||
ByteBuf buf = (ByteBuf) m;
|
||||
final int readerIndex = buf.readerIndex();
|
||||
final int readableBytes = buf.writerIndex() - readerIndex;
|
||||
@ -445,7 +446,7 @@ public final class ChannelOutboundBuffer {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
i = i + 1 & mask;
|
||||
}
|
||||
this.nioBufferCount = nioBufferCount;
|
||||
|
Loading…
Reference in New Issue
Block a user