Disable timeouts if they are set to 0
This commit is contained in:
parent
adebda1560
commit
7514a82c35
@ -290,23 +290,32 @@ public class SslHandler
|
|||||||
public ChannelFuture handshake(final ChannelFuture future) {
|
public ChannelFuture handshake(final ChannelFuture future) {
|
||||||
final ChannelHandlerContext ctx = this.ctx;
|
final ChannelHandlerContext ctx = this.ctx;
|
||||||
|
|
||||||
ctx.executor().schedule(new Runnable() {
|
final ScheduledFuture<?> timeoutFuture;
|
||||||
@Override
|
if (handshakeTimeoutMillis > 0) {
|
||||||
public void run() {
|
timeoutFuture = ctx.executor().schedule(new Runnable() {
|
||||||
if (future.isDone()) {
|
@Override
|
||||||
return;
|
public void run() {
|
||||||
}
|
if (future.isDone()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SSLException e = new SSLException("handshake timed out");
|
||||||
|
future.setFailure(e);
|
||||||
|
ctx.fireExceptionCaught(e);
|
||||||
|
ctx.close();
|
||||||
|
}
|
||||||
|
}, handshakeTimeoutMillis, TimeUnit.MILLISECONDS);
|
||||||
|
} else {
|
||||||
|
timeoutFuture = null;
|
||||||
|
}
|
||||||
|
|
||||||
SSLException e = new SSLException("handshake timed out");
|
|
||||||
future.setFailure(e);
|
|
||||||
ctx.fireExceptionCaught(e);
|
|
||||||
ctx.close();
|
|
||||||
}
|
|
||||||
}, handshakeTimeoutMillis, TimeUnit.MILLISECONDS);
|
|
||||||
ctx.executor().execute(new Runnable() {
|
ctx.executor().execute(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
|
if (timeoutFuture != null) {
|
||||||
|
timeoutFuture.cancel(false);
|
||||||
|
}
|
||||||
engine.beginHandshake();
|
engine.beginHandshake();
|
||||||
handshakeFutures.add(future);
|
handshakeFutures.add(future);
|
||||||
flush(ctx, ctx.newFuture());
|
flush(ctx, ctx.newFuture());
|
||||||
@ -912,23 +921,31 @@ public class SslHandler
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Force-close the connection if close_notify is not fully sent in time.
|
final ScheduledFuture<?> timeoutFuture;
|
||||||
final ScheduledFuture<?> timeoutFuture = ctx.executor().schedule(new Runnable() {
|
if (closeNotifyTimeoutMillis > 0) {
|
||||||
@Override
|
// Force-close the connection if close_notify is not fully sent in time.
|
||||||
public void run() {
|
timeoutFuture = ctx.executor().schedule(new Runnable() {
|
||||||
logger.warn(
|
@Override
|
||||||
ctx.channel() + " last lssssswrite attempt timed out." +
|
public void run() {
|
||||||
" Force-closing the connection.");
|
logger.warn(
|
||||||
ctx.close(closeFuture);
|
ctx.channel() + " last lssssswrite attempt timed out." +
|
||||||
}
|
" Force-closing the connection.");
|
||||||
}, closeNotifyTimeoutMillis, TimeUnit.MILLISECONDS);
|
ctx.close(closeFuture);
|
||||||
|
}
|
||||||
|
}, closeNotifyTimeoutMillis, TimeUnit.MILLISECONDS);
|
||||||
|
} else {
|
||||||
|
timeoutFuture = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Close the connection if close_notify is sent in time.
|
// Close the connection if close_notify is sent in time.
|
||||||
flushFuture.addListener(new ChannelFutureListener() {
|
flushFuture.addListener(new ChannelFutureListener() {
|
||||||
@Override
|
@Override
|
||||||
public void operationComplete(ChannelFuture f)
|
public void operationComplete(ChannelFuture f)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
timeoutFuture.cancel(false);
|
if (timeoutFuture != null) {
|
||||||
|
timeoutFuture.cancel(false);
|
||||||
|
}
|
||||||
if (ctx.channel().isActive()) {
|
if (ctx.channel().isActive()) {
|
||||||
ctx.close(closeFuture);
|
ctx.close(closeFuture);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user