Ensure we not schedule multiple timeouts for close notify
Motivation: We should only schedule one timeout to wait for the close notify to be done. Modifications: Keep track of if we already scheduled a timeout for close notify and if so not schedule another one. Result: No duplicated timeouts.
This commit is contained in:
parent
d60cd0231d
commit
2e92a2f5cd
@ -400,6 +400,7 @@ public class SslHandler extends ByteToMessageDecoder implements ChannelOutboundH
|
|||||||
private boolean needsFlush;
|
private boolean needsFlush;
|
||||||
|
|
||||||
private boolean outboundClosed;
|
private boolean outboundClosed;
|
||||||
|
private boolean closeNotify;
|
||||||
|
|
||||||
private int packetLength;
|
private int packetLength;
|
||||||
|
|
||||||
@ -1591,16 +1592,27 @@ public class SslHandler extends ByteToMessageDecoder implements ChannelOutboundH
|
|||||||
try {
|
try {
|
||||||
flush(ctx, closeNotifyPromise);
|
flush(ctx, closeNotifyPromise);
|
||||||
} finally {
|
} finally {
|
||||||
// It's important that we do not pass the original ChannelPromise to safeClose(...) as when flush(....)
|
if (!closeNotify) {
|
||||||
// throws an Exception it will be propagated to the AbstractChannelHandlerContext which will try
|
closeNotify = true;
|
||||||
// to fail the promise because of this. This will then fail as it was already completed by safeClose(...).
|
// It's important that we do not pass the original ChannelPromise to safeClose(...) as when flush(....)
|
||||||
// We create a new ChannelPromise and try to notify the original ChannelPromise
|
// throws an Exception it will be propagated to the AbstractChannelHandlerContext which will try
|
||||||
// once it is complete. If we fail to do so we just ignore it as in this case it was failed already
|
// to fail the promise because of this. This will then fail as it was already completed by
|
||||||
// because of a propagated Exception.
|
// safeClose(...). We create a new ChannelPromise and try to notify the original ChannelPromise
|
||||||
//
|
// once it is complete. If we fail to do so we just ignore it as in this case it was failed already
|
||||||
// See https://github.com/netty/netty/issues/5931
|
// because of a propagated Exception.
|
||||||
safeClose(ctx, closeNotifyPromise, ctx.newPromise().addListener(
|
//
|
||||||
new ChannelPromiseNotifier(false, promise)));
|
// See https://github.com/netty/netty/issues/5931
|
||||||
|
safeClose(ctx, closeNotifyPromise, ctx.newPromise().addListener(
|
||||||
|
new ChannelPromiseNotifier(false, promise)));
|
||||||
|
} else {
|
||||||
|
/// We already handling the close_notify so just attach the promise to the sslClosePromise.
|
||||||
|
sslClosePromise.addListener(new FutureListener<Channel>() {
|
||||||
|
@Override
|
||||||
|
public void operationComplete(Future<Channel> future) {
|
||||||
|
promise.setSuccess();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user