Make uninitialization code in DefaultChannel easier to understand
.. by fixing bad / outdated method names
This commit is contained in:
parent
a331c87a7a
commit
670d3f53a8
@ -439,7 +439,9 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
|
|||||||
freeBuffer(outByteBuf);
|
freeBuffer(outByteBuf);
|
||||||
freeBuffer(outMsgBuf);
|
freeBuffer(outMsgBuf);
|
||||||
} finally {
|
} finally {
|
||||||
free();
|
flags |= FLAG_FREED | FLAG_FREED_INBOUND | FLAG_FREED_OUTBOUND;
|
||||||
|
freeNextInboundBridgeFeeder();
|
||||||
|
freeNextOutboundBridgeFeeder();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -454,20 +456,12 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void free() {
|
|
||||||
flags |= FLAG_FREED;
|
|
||||||
freeInbound();
|
|
||||||
freeOutbound();
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isInboundFreed() {
|
private boolean isInboundFreed() {
|
||||||
return (flags & FLAG_FREED_INBOUND) != 0;
|
return (flags & FLAG_FREED_INBOUND) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void freeInbound() {
|
private void freeNextInboundBridgeFeeder() {
|
||||||
// Release the bridge feeder
|
// Release the bridge feeder
|
||||||
flags |= FLAG_FREED_INBOUND;
|
|
||||||
|
|
||||||
NextBridgeFeeder feeder;
|
NextBridgeFeeder feeder;
|
||||||
feeder = nextInBridgeFeeder;
|
feeder = nextInBridgeFeeder;
|
||||||
if (feeder != null) {
|
if (feeder != null) {
|
||||||
@ -489,10 +483,8 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
|
|||||||
return (flags & FLAG_FREED_OUTBOUND) != 0;
|
return (flags & FLAG_FREED_OUTBOUND) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void freeOutbound() {
|
private void freeNextOutboundBridgeFeeder() {
|
||||||
// Release the bridge feeder
|
// Release the bridge feeder
|
||||||
flags |= FLAG_FREED_OUTBOUND;
|
|
||||||
|
|
||||||
NextBridgeFeeder feeder = nextOutBridgeFeeder;
|
NextBridgeFeeder feeder = nextOutBridgeFeeder;
|
||||||
if (feeder != null) {
|
if (feeder != null) {
|
||||||
feeder.release();
|
feeder.release();
|
||||||
@ -1461,75 +1453,77 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
|
|||||||
invokeFlush0(promise);
|
invokeFlush0(promise);
|
||||||
}
|
}
|
||||||
|
|
||||||
void invokeFreeInboundBuffer() {
|
void freeInbound() {
|
||||||
EventExecutor executor = executor();
|
EventExecutor executor = executor();
|
||||||
if (executor.inEventLoop()) {
|
if (executor.inEventLoop()) {
|
||||||
invokeFreeInboundBuffer0();
|
freeInbound0();
|
||||||
} else {
|
} else {
|
||||||
executor.execute(new Runnable() {
|
executor.execute(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
invokeFreeInboundBuffer0();
|
freeInbound0();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void invokeFreeInboundBuffer0() {
|
private void freeInbound0() {
|
||||||
try {
|
try {
|
||||||
freeBuffer(inByteBuf);
|
freeBuffer(inByteBuf);
|
||||||
freeBuffer(inMsgBuf);
|
freeBuffer(inMsgBuf);
|
||||||
} finally {
|
} finally {
|
||||||
freeInbound();
|
flags |= FLAG_FREED_INBOUND;
|
||||||
|
freeNextInboundBridgeFeeder();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (next != null) {
|
if (next != null) {
|
||||||
DefaultChannelHandlerContext nextCtx = findContextInbound();
|
DefaultChannelHandlerContext nextCtx = findContextInbound();
|
||||||
nextCtx.invokeFreeInboundBuffer();
|
nextCtx.freeInbound();
|
||||||
} else {
|
} else {
|
||||||
// Freed all inbound buffers. Free all outbound buffers in a reverse order.
|
// Freed all inbound buffers. Free all outbound buffers in a reverse order.
|
||||||
findContextOutbound().invokeFreeOutboundBuffer();
|
findContextOutbound().freeOutbound();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Invocation initiated by {@link #invokeFreeInboundBuffer0()} after freeing all inbound buffers. */
|
/** Invocation initiated by {@link #freeInbound0()} after freeing all inbound buffers. */
|
||||||
private void invokeFreeOutboundBuffer() {
|
private void freeOutbound() {
|
||||||
EventExecutor executor = executor();
|
EventExecutor executor = executor();
|
||||||
if (next == null) {
|
if (next == null) {
|
||||||
if (executor.inEventLoop()) {
|
if (executor.inEventLoop()) {
|
||||||
invokeFreeOutboundBuffer0();
|
freeOutbound0();
|
||||||
} else {
|
} else {
|
||||||
executor.execute(new Runnable() {
|
executor.execute(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
invokeFreeOutboundBuffer0();
|
freeOutbound0();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (executor.inEventLoop()) {
|
if (executor.inEventLoop()) {
|
||||||
invokeFreeOutboundBuffer0();
|
freeOutbound0();
|
||||||
} else {
|
} else {
|
||||||
executor.execute(new Runnable() {
|
executor.execute(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
invokeFreeOutboundBuffer0();
|
freeOutbound0();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void invokeFreeOutboundBuffer0() {
|
private void freeOutbound0() {
|
||||||
try {
|
try {
|
||||||
freeBuffer(outByteBuf);
|
freeBuffer(outByteBuf);
|
||||||
freeBuffer(outMsgBuf);
|
freeBuffer(outMsgBuf);
|
||||||
} finally {
|
} finally {
|
||||||
freeOutbound();
|
flags |= FLAG_FREED_OUTBOUND;
|
||||||
|
freeNextOutboundBridgeFeeder();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prev != null) {
|
if (prev != null) {
|
||||||
findContextOutbound().invokeFreeOutboundBuffer();
|
findContextOutbound().freeOutbound();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -782,7 +782,7 @@ final class DefaultChannelPipeline implements ChannelPipeline {
|
|||||||
|
|
||||||
// Free all buffers if channel is closed and unregistered.
|
// Free all buffers if channel is closed and unregistered.
|
||||||
if (!channel.isOpen()) {
|
if (!channel.isOpen()) {
|
||||||
head.invokeFreeInboundBuffer();
|
head.freeInbound();
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user