Fixed a bug where NioWorker.register() hangs up with high CPU consumption when it failed to open a selector.
This commit is contained in:
parent
486218ab28
commit
7f1ff668f7
@ -89,14 +89,19 @@ class NioWorker implements Runnable {
|
||||
boolean firstChannel = started.compareAndSet(false, true);
|
||||
Selector selector;
|
||||
if (firstChannel) {
|
||||
boolean success = false;
|
||||
selectorGuard.writeLock().lock();
|
||||
try {
|
||||
this.selector = selector = Selector.open();
|
||||
success = true;
|
||||
} catch (IOException e) {
|
||||
throw new ChannelException(
|
||||
"Failed to create a selector.", e);
|
||||
} finally {
|
||||
selectorGuard.writeLock().unlock();
|
||||
if (!success) {
|
||||
started.compareAndSet(true, false);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
selector = this.selector;
|
||||
|
Loading…
Reference in New Issue
Block a user