[#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:
Norman Maurer 2014-04-21 11:16:07 +02:00
parent 7ae40ace32
commit ff4a89b5ae

View File

@ -100,7 +100,7 @@ abstract class AbstractEpollChannel extends AbstractChannel {
protected void doBeginRead() throws Exception {
if ((flags & readFlag) == 0) {
flags |= readFlag;
((EpollEventLoop) eventLoop()).modify(this);
modifyEvents();
}
}
@ -126,13 +126,19 @@ abstract class AbstractEpollChannel extends AbstractChannel {
protected final void setEpollOut() {
if ((flags & Native.EPOLLOUT) == 0) {
flags |= Native.EPOLLOUT;
((EpollEventLoop) eventLoop()).modify(this);
modifyEvents();
}
}
protected final void clearEpollOut() {
if ((flags & Native.EPOLLOUT) != 0) {
flags &= ~Native.EPOLLOUT;
modifyEvents();
}
}
private void modifyEvents() {
if (isOpen()) {
((EpollEventLoop) eventLoop()).modify(this);
}
}
@ -200,7 +206,7 @@ abstract class AbstractEpollChannel extends AbstractChannel {
protected final void clearEpollIn0() {
if ((flags & readFlag) != 0) {
flags &= ~readFlag;
((EpollEventLoop) eventLoop()).modify(AbstractEpollChannel.this);
modifyEvents();
}
}
}