[#2414] Fix IllegalStateException when try to configure AbstractEpollChannel once it is deregistered
Motivation: AbstractEpollChannel.clearEpollIn() throws an IllegalStateException if a user tries to change the autoRead configuration for the Channel and the Channel is not registered on an EventLoop yet. This makes it for example impossible to set AUTO_READ to false via the ServerBootstrap as the configuration is modifed before the Channel is registered. Modification: Check if the Channel is registered and if not just modify the flags directly so they are respected once the Channel is registered Result: It is possible now to configure AUTO_READ via the ServerBootstrap
This commit is contained in:
parent
60830012df
commit
778ee88ada
@ -105,6 +105,8 @@ abstract class AbstractEpollChannel extends AbstractChannel {
|
||||
}
|
||||
|
||||
final void clearEpollIn() {
|
||||
// Only clear if registered with an EventLoop as otherwise
|
||||
if (isRegistered()) {
|
||||
final EventLoop loop = eventLoop();
|
||||
final AbstractEpollUnsafe unsafe = (AbstractEpollUnsafe) unsafe();
|
||||
if (loop.inEventLoop()) {
|
||||
@ -121,6 +123,11 @@ abstract class AbstractEpollChannel extends AbstractChannel {
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// The EventLoop is not registered atm so just update the flags so the correct value
|
||||
// will be used once the channel is registered
|
||||
flags &= ~readFlag;
|
||||
}
|
||||
}
|
||||
|
||||
protected final void setEpollOut() {
|
||||
|
Loading…
Reference in New Issue
Block a user