Always release the sslEngine inside SslHandler's handlerRemoved0 (#11605)
Motivation: Make SslHandler's handlerRemoved0 method release the sslEngine even if it fails in the middle. See details in https://github.com/netty/netty/issues/11595. Modifications: Wrap the release of sslEngine into a finally block. Result: The sslEngine would be released eventually. Co-authored-by: Chen Liu <cliu@splunk.com>
This commit is contained in:
parent
fb1face924
commit
ea5bc27c83
@ -34,7 +34,6 @@ import io.netty.handler.codec.ByteToMessageDecoder;
|
|||||||
import io.netty.handler.codec.DecoderException;
|
import io.netty.handler.codec.DecoderException;
|
||||||
import io.netty.handler.codec.UnsupportedMessageTypeException;
|
import io.netty.handler.codec.UnsupportedMessageTypeException;
|
||||||
import io.netty.util.ReferenceCountUtil;
|
import io.netty.util.ReferenceCountUtil;
|
||||||
import io.netty.util.ReferenceCounted;
|
|
||||||
import io.netty.util.concurrent.DefaultPromise;
|
import io.netty.util.concurrent.DefaultPromise;
|
||||||
import io.netty.util.concurrent.EventExecutor;
|
import io.netty.util.concurrent.EventExecutor;
|
||||||
import io.netty.util.concurrent.Future;
|
import io.netty.util.concurrent.Future;
|
||||||
@ -650,6 +649,7 @@ public class SslHandler extends ByteToMessageDecoder {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handlerRemoved0(ChannelHandlerContext ctx) throws Exception {
|
public void handlerRemoved0(ChannelHandlerContext ctx) throws Exception {
|
||||||
|
try {
|
||||||
if (!pendingUnencryptedWrites.isEmpty()) {
|
if (!pendingUnencryptedWrites.isEmpty()) {
|
||||||
// Check if queue is not empty first because create a new ChannelException is expensive
|
// Check if queue is not empty first because create a new ChannelException is expensive
|
||||||
pendingUnencryptedWrites.releaseAndFailAll(ctx,
|
pendingUnencryptedWrites.releaseAndFailAll(ctx,
|
||||||
@ -673,9 +673,8 @@ public class SslHandler extends ByteToMessageDecoder {
|
|||||||
}
|
}
|
||||||
notifyClosePromise(cause);
|
notifyClosePromise(cause);
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
if (engine instanceof ReferenceCounted) {
|
ReferenceCountUtil.release(engine);
|
||||||
((ReferenceCounted) engine).release();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user