Add a workaround for the 100% cpu usage that can happen because of an endless loop. See #535
This commit is contained in:
parent
bcc9d7c5ae
commit
85e55eebd8
@ -20,6 +20,7 @@ import static org.jboss.netty.channel.Channels.*;
|
||||
import java.io.IOException;
|
||||
import java.net.ConnectException;
|
||||
import java.net.SocketAddress;
|
||||
import java.nio.channels.CancelledKeyException;
|
||||
import java.nio.channels.ClosedChannelException;
|
||||
import java.nio.channels.SelectionKey;
|
||||
import java.nio.channels.Selector;
|
||||
@ -362,8 +363,17 @@ class NioClientSocketPipelineSink extends AbstractNioChannelSink {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (k.isConnectable()) {
|
||||
connect(k);
|
||||
try {
|
||||
if (k.isConnectable()) {
|
||||
connect(k);
|
||||
}
|
||||
} catch (CancelledKeyException t) {
|
||||
// Catch CancelledKeyException which may get thrown.
|
||||
NioClientSocketChannel ch = (NioClientSocketChannel) k.attachment();
|
||||
ch.connectFuture.setFailure(t);
|
||||
fireExceptionCaught(ch, t);
|
||||
k.cancel(); // Some JDK implementations run into an infinite loop without this.
|
||||
ch.worker.close(ch, succeededFuture(ch));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user