Cleanup after commit fc1cdc991e71f504cf0d9fdb5aa60034fda04a28
This commit is contained in:
parent
8eb158d83c
commit
bcfd3a493c
@ -40,7 +40,6 @@ import java.security.AccessController;
|
|||||||
import java.security.PrivilegedAction;
|
import java.security.PrivilegedAction;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.ConcurrentModificationException;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -340,35 +339,32 @@ public final class NioEventLoop extends SingleThreadEventLoop {
|
|||||||
|
|
||||||
// Register all channels to the new Selector.
|
// Register all channels to the new Selector.
|
||||||
int nChannels = 0;
|
int nChannels = 0;
|
||||||
for (;;) {
|
for (SelectionKey key: oldSelector.keys()) {
|
||||||
for (SelectionKey key: oldSelector.keys()) {
|
Object a = key.attachment();
|
||||||
Object a = key.attachment();
|
try {
|
||||||
try {
|
if (!key.isValid() || key.channel().keyFor(newSelector) != null) {
|
||||||
if (!key.isValid() || key.channel().keyFor(newSelector) != null) {
|
continue;
|
||||||
continue;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
int interestOps = key.interestOps();
|
int interestOps = key.interestOps();
|
||||||
key.cancel();
|
key.cancel();
|
||||||
SelectionKey newKey = key.channel().register(newSelector, interestOps, a);
|
SelectionKey newKey = key.channel().register(newSelector, interestOps, a);
|
||||||
if (a instanceof AbstractNioChannel) {
|
if (a instanceof AbstractNioChannel) {
|
||||||
// Update SelectionKey
|
// Update SelectionKey
|
||||||
((AbstractNioChannel) a).selectionKey = newKey;
|
((AbstractNioChannel) a).selectionKey = newKey;
|
||||||
}
|
}
|
||||||
nChannels ++;
|
nChannels ++;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.warn("Failed to re-register a Channel to the new Selector.", e);
|
logger.warn("Failed to re-register a Channel to the new Selector.", e);
|
||||||
if (a instanceof AbstractNioChannel) {
|
if (a instanceof AbstractNioChannel) {
|
||||||
AbstractNioChannel ch = (AbstractNioChannel) a;
|
AbstractNioChannel ch = (AbstractNioChannel) a;
|
||||||
ch.unsafe().close(ch.unsafe().voidPromise());
|
ch.unsafe().close(ch.unsafe().voidPromise());
|
||||||
} else {
|
} else {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
NioTask<SelectableChannel> task = (NioTask<SelectableChannel>) a;
|
NioTask<SelectableChannel> task = (NioTask<SelectableChannel>) a;
|
||||||
invokeChannelUnregistered(task, key, e);
|
invokeChannelUnregistered(task, key, e);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
selector = newSelector;
|
selector = newSelector;
|
||||||
@ -645,10 +641,6 @@ public final class NioEventLoop extends SingleThreadEventLoop {
|
|||||||
// to a spin loop
|
// to a spin loop
|
||||||
if ((readyOps & (SelectionKey.OP_READ | SelectionKey.OP_ACCEPT)) != 0 || readyOps == 0) {
|
if ((readyOps & (SelectionKey.OP_READ | SelectionKey.OP_ACCEPT)) != 0 || readyOps == 0) {
|
||||||
unsafe.read();
|
unsafe.read();
|
||||||
if (!ch.isOpen()) {
|
|
||||||
// Connection already closed - no need to handle write.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (CancelledKeyException ignored) {
|
} catch (CancelledKeyException ignored) {
|
||||||
unsafe.close(unsafe.voidPromise());
|
unsafe.close(unsafe.voidPromise());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user