[#3443] Fix IllegalStateException which could be triggered when the channel goes inactive during the eventloop processing
Motivation:
This is a regression that was introduced as part of 6b941e9bdb
. The regression could produce an "infinity" triggering of IllegalStateException if a channel goes inactive while process the events for it.
Modifications:
Correctly check if the channel is still active before trigger the callbacks.
Result:
No more IllegalStateException
This commit is contained in:
parent
88dae15bc2
commit
5bb1377072
@ -310,17 +310,24 @@ final class EpollEventLoop extends SingleThreadEventLoop {
|
||||
boolean write = (ev & Native.EPOLLOUT) != 0;
|
||||
|
||||
AbstractEpollUnsafe unsafe = (AbstractEpollUnsafe) ch.unsafe();
|
||||
if (write) {
|
||||
|
||||
if (close) {
|
||||
unsafe.epollRdHupReady();
|
||||
}
|
||||
|
||||
// We need to check if the channel is still open before try to trigger the
|
||||
// callbacks as otherwise we may trigger an IllegalStateException when try
|
||||
// to access the file descriptor.
|
||||
//
|
||||
// See https://github.com/netty/netty/issues/3443
|
||||
if (write && ch.isOpen()) {
|
||||
// force flush of data as the epoll is writable again
|
||||
unsafe.epollOutReady();
|
||||
}
|
||||
if (read) {
|
||||
if (read && ch.isOpen()) {
|
||||
// Something is ready to read, so consume it now
|
||||
unsafe.epollInReady();
|
||||
}
|
||||
if (close) {
|
||||
unsafe.epollRdHupReady();
|
||||
}
|
||||
} else {
|
||||
// We received an event for an fd which we not use anymore. Remove it from the epoll_event set.
|
||||
Native.epollCtlDel(epollFd, fd);
|
||||
|
Loading…
Reference in New Issue
Block a user