[#2414] Fix RuntimeException during modify events via EpollEventLoop
Motivation: We are currently try to modify the events via EpollEventLoop even when the channel was closed before and so the fd was set to -1. This fails with a RuntimeException in this case. Modification: Always check if the Channel is still open before try to modify the events. Result: No more RuntimeException because of a not open channel
This commit is contained in:
parent
59a1d29aa0
commit
60830012df
@ -100,7 +100,7 @@ abstract class AbstractEpollChannel extends AbstractChannel {
|
|||||||
protected void doBeginRead() throws Exception {
|
protected void doBeginRead() throws Exception {
|
||||||
if ((flags & readFlag) == 0) {
|
if ((flags & readFlag) == 0) {
|
||||||
flags |= readFlag;
|
flags |= readFlag;
|
||||||
((EpollEventLoop) eventLoop()).modify(this);
|
modifyEvents();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,13 +126,19 @@ abstract class AbstractEpollChannel extends AbstractChannel {
|
|||||||
protected final void setEpollOut() {
|
protected final void setEpollOut() {
|
||||||
if ((flags & Native.EPOLLOUT) == 0) {
|
if ((flags & Native.EPOLLOUT) == 0) {
|
||||||
flags |= Native.EPOLLOUT;
|
flags |= Native.EPOLLOUT;
|
||||||
((EpollEventLoop) eventLoop()).modify(this);
|
modifyEvents();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final void clearEpollOut() {
|
protected final void clearEpollOut() {
|
||||||
if ((flags & Native.EPOLLOUT) != 0) {
|
if ((flags & Native.EPOLLOUT) != 0) {
|
||||||
flags &= ~Native.EPOLLOUT;
|
flags &= ~Native.EPOLLOUT;
|
||||||
|
modifyEvents();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void modifyEvents() {
|
||||||
|
if (isOpen()) {
|
||||||
((EpollEventLoop) eventLoop()).modify(this);
|
((EpollEventLoop) eventLoop()).modify(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -200,7 +206,7 @@ abstract class AbstractEpollChannel extends AbstractChannel {
|
|||||||
protected final void clearEpollIn0() {
|
protected final void clearEpollIn0() {
|
||||||
if ((flags & readFlag) != 0) {
|
if ((flags & readFlag) != 0) {
|
||||||
flags &= ~readFlag;
|
flags &= ~readFlag;
|
||||||
((EpollEventLoop) eventLoop()).modify(AbstractEpollChannel.this);
|
modifyEvents();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user