Free the cleared buffer as early as possible / Better naming
This commit is contained in:
parent
dc13b68632
commit
2040b07849
@ -198,12 +198,12 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
|
||||
outMsgBuf = null;
|
||||
}
|
||||
|
||||
void forwardBufferContentAndRemove(
|
||||
void forwardBufferContentAndFree(
|
||||
final DefaultChannelHandlerContext forwardPrev, final DefaultChannelHandlerContext forwardNext) {
|
||||
|
||||
boolean flush = false;
|
||||
boolean inboundBufferUpdated = false;
|
||||
try {
|
||||
boolean flush = false;
|
||||
boolean inboundBufferUpdated = false;
|
||||
if (!isOutboundFreed()) {
|
||||
if (hasOutboundByteBuffer() && outboundByteBuffer().isReadable()) {
|
||||
ByteBuf forwardPrevBuf;
|
||||
@ -251,40 +251,40 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (flush) {
|
||||
EventExecutor executor = executor();
|
||||
Thread currentThread = Thread.currentThread();
|
||||
if (executor.inEventLoop(currentThread)) {
|
||||
invokePrevFlush(newPromise(), currentThread, findContextOutboundInclusive(forwardPrev));
|
||||
} else {
|
||||
executor.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
invokePrevFlush(newPromise(), Thread.currentThread(),
|
||||
findContextOutboundInclusive(forwardPrev));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (inboundBufferUpdated) {
|
||||
EventExecutor executor = executor();
|
||||
if (executor.inEventLoop()) {
|
||||
fireInboundBufferUpdated0(findContextInboundInclusive(forwardNext));
|
||||
} else {
|
||||
executor.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
fireInboundBufferUpdated0(findContextInboundInclusive(forwardNext));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
flags |= FLAG_REMOVED;
|
||||
freeAllIfRemoved();
|
||||
}
|
||||
|
||||
if (flush) {
|
||||
EventExecutor executor = executor();
|
||||
Thread currentThread = Thread.currentThread();
|
||||
if (executor.inEventLoop(currentThread)) {
|
||||
invokePrevFlush(newPromise(), currentThread, findContextOutboundInclusive(forwardPrev));
|
||||
} else {
|
||||
executor.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
invokePrevFlush(newPromise(), Thread.currentThread(),
|
||||
findContextOutboundInclusive(forwardPrev));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (inboundBufferUpdated) {
|
||||
EventExecutor executor = executor();
|
||||
if (executor.inEventLoop()) {
|
||||
fireInboundBufferUpdated0(findContextInboundInclusive(forwardNext));
|
||||
} else {
|
||||
executor.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
fireInboundBufferUpdated0(findContextInboundInclusive(forwardNext));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static DefaultChannelHandlerContext findContextOutboundInclusive(DefaultChannelHandlerContext ctx) {
|
||||
|
@ -541,7 +541,7 @@ final class DefaultChannelPipeline implements ChannelPipeline {
|
||||
// Finish removal by forwarding buffer content and freeing the buffers.
|
||||
if (forward) {
|
||||
try {
|
||||
ctx.forwardBufferContentAndRemove(ctxPrev, ctxNext);
|
||||
ctx.forwardBufferContentAndFree(ctxPrev, ctxNext);
|
||||
} catch (Throwable t) {
|
||||
fireExceptionCaught(new ChannelPipelineException(
|
||||
"failed to forward buffer content of " + ctx.handler().getClass().getName(), t));
|
||||
|
Loading…
Reference in New Issue
Block a user