[#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
ff4a89b5ae
commit
9afb56c3c6
|
@ -105,21 +105,28 @@ abstract class AbstractEpollChannel extends AbstractChannel {
|
||||||
}
|
}
|
||||||
|
|
||||||
final void clearEpollIn() {
|
final void clearEpollIn() {
|
||||||
final EventLoop loop = eventLoop();
|
// Only clear if registered with an EventLoop as otherwise
|
||||||
final AbstractEpollUnsafe unsafe = (AbstractEpollUnsafe) unsafe();
|
if (isRegistered()) {
|
||||||
if (loop.inEventLoop()) {
|
final EventLoop loop = eventLoop();
|
||||||
unsafe.clearEpollIn0();
|
final AbstractEpollUnsafe unsafe = (AbstractEpollUnsafe) unsafe();
|
||||||
} else {
|
if (loop.inEventLoop()) {
|
||||||
// schedule a task to clear the EPOLLIN as it is not safe to modify it directly
|
unsafe.clearEpollIn0();
|
||||||
loop.execute(new OneTimeTask() {
|
} else {
|
||||||
@Override
|
// schedule a task to clear the EPOLLIN as it is not safe to modify it directly
|
||||||
public void run() {
|
loop.execute(new OneTimeTask() {
|
||||||
if (!config().isAutoRead() && !unsafe.readPending) {
|
@Override
|
||||||
// Still no read triggered so clear it now
|
public void run() {
|
||||||
unsafe.clearEpollIn0();
|
if (!config().isAutoRead() && !unsafe.readPending) {
|
||||||
|
// Still no read triggered so clear it now
|
||||||
|
unsafe.clearEpollIn0();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
}
|
||||||
|
} 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user