Move marking ChannelPromise for writes uncancellable to addFlush for keep things simple
This commit is contained in:
parent
5612472ae6
commit
1c9c797e82
@ -174,6 +174,18 @@ public final class ChannelOutboundBuffer {
|
|||||||
|
|
||||||
void addFlush() {
|
void addFlush() {
|
||||||
unflushed = tail;
|
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 {
|
} else {
|
||||||
// TODO: Think of a smart way to handle ByteBufHolder messages
|
// TODO: Think of a smart way to handle ByteBufHolder messages
|
||||||
Entry entry = buffer[flushed];
|
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;
|
Object msg = entry.msg;
|
||||||
if (threadLocalDirectBufferSize <= 0 || !preferDirect) {
|
if (threadLocalDirectBufferSize <= 0 || !preferDirect) {
|
||||||
return msg;
|
return msg;
|
||||||
@ -400,11 +406,6 @@ public final class ChannelOutboundBuffer {
|
|||||||
Entry entry = buffer[i];
|
Entry entry = buffer[i];
|
||||||
|
|
||||||
if (!entry.cancelled) {
|
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;
|
ByteBuf buf = (ByteBuf) m;
|
||||||
final int readerIndex = buf.readerIndex();
|
final int readerIndex = buf.readerIndex();
|
||||||
final int readableBytes = buf.writerIndex() - readerIndex;
|
final int readableBytes = buf.writerIndex() - readerIndex;
|
||||||
@ -445,7 +446,7 @@ public final class ChannelOutboundBuffer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
i = i + 1 & mask;
|
i = i + 1 & mask;
|
||||||
}
|
}
|
||||||
this.nioBufferCount = nioBufferCount;
|
this.nioBufferCount = nioBufferCount;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user