Merge pull request #555 from netty/nio_100percent_cpu_fix
Partial fix for 100% cpu usage when using nio client. See #535
This commit is contained in:
commit
573fbfa518
@ -362,8 +362,16 @@ class NioClientSocketPipelineSink extends AbstractNioChannelSink {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (k.isConnectable()) {
|
try {
|
||||||
connect(k);
|
if (k.isConnectable()) {
|
||||||
|
connect(k);
|
||||||
|
}
|
||||||
|
} catch (Throwable t) {
|
||||||
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -398,18 +406,11 @@ class NioClientSocketPipelineSink extends AbstractNioChannelSink {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void connect(SelectionKey k) {
|
private void connect(SelectionKey k) throws IOException {
|
||||||
NioClientSocketChannel ch = (NioClientSocketChannel) k.attachment();
|
NioClientSocketChannel ch = (NioClientSocketChannel) k.attachment();
|
||||||
try {
|
if (ch.channel.finishConnect()) {
|
||||||
if (ch.channel.finishConnect()) {
|
k.cancel();
|
||||||
k.cancel();
|
ch.worker.register(ch, ch.connectFuture);
|
||||||
ch.worker.register(ch, ch.connectFuture);
|
|
||||||
}
|
|
||||||
} catch (Throwable t) {
|
|
||||||
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