[#924] [#914] Fix high CPU usage which was caused because the OP_CONNECT flag was not cleared after the connect was complete
This commit is contained in:
parent
04bae9bceb
commit
eb91a6d4e6
@ -233,7 +233,6 @@ public final class NioEventLoop extends SingleThreadEventLoop {
|
|||||||
long minSelectTimeout = SelectorUtil.SELECT_TIMEOUT_NANOS / 100 * 80;
|
long minSelectTimeout = SelectorUtil.SELECT_TIMEOUT_NANOS / 100 * 80;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
|
||||||
wakenUp.set(false);
|
wakenUp.set(false);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -418,6 +417,12 @@ public final class NioEventLoop extends SingleThreadEventLoop {
|
|||||||
processWritable(k, ch);
|
processWritable(k, ch);
|
||||||
}
|
}
|
||||||
if ((readyOps & SelectionKey.OP_CONNECT) != 0) {
|
if ((readyOps & SelectionKey.OP_CONNECT) != 0) {
|
||||||
|
// remove OP_CONNECT as otherwise Selector.select(..) will always return without blocking
|
||||||
|
// See https://github.com/netty/netty/issues/924
|
||||||
|
int ops = k.interestOps();
|
||||||
|
ops &= ~SelectionKey.OP_CONNECT;
|
||||||
|
k.interestOps(ops);
|
||||||
|
|
||||||
unsafe.finishConnect();
|
unsafe.finishConnect();
|
||||||
}
|
}
|
||||||
} catch (CancelledKeyException e) {
|
} catch (CancelledKeyException e) {
|
||||||
|
Loading…
Reference in New Issue
Block a user