Correctly handle remove from epoll and EPOLLRDHUP. Also fix a bug with removing EPOLLIN and EPOLLOUT

This commit is contained in:
Norman Maurer 2014-02-19 11:57:41 +01:00
parent 23374a1854
commit eb143d6d6e
2 changed files with 11 additions and 3 deletions

View File

@ -65,6 +65,10 @@ abstract class AbstractEpollChannel extends AbstractChannel {
@Override @Override
protected void doClose() throws Exception { protected void doClose() throws Exception {
active = false; active = false;
// deregister from epoll now
doDeregister();
int fd = this.fd; int fd = this.fd;
this.fd = -1; this.fd = -1;
Native.close(fd); Native.close(fd);
@ -110,7 +114,7 @@ abstract class AbstractEpollChannel extends AbstractChannel {
protected final void clearEpollIn() { protected final void clearEpollIn() {
if ((flags & readFlag) != 0) { if ((flags & readFlag) != 0) {
flags = ~readFlag; flags &= ~readFlag;
((EpollEventLoop) eventLoop()).modify(this); ((EpollEventLoop) eventLoop()).modify(this);
} }
} }

View File

@ -101,7 +101,7 @@ public final class EpollSocketChannel extends AbstractEpollChannel implements So
private void clearEpollOut() { private void clearEpollOut() {
if ((flags & Native.EPOLLOUT) != 0) { if ((flags & Native.EPOLLOUT) != 0) {
flags = ~Native.EPOLLOUT; flags &= ~Native.EPOLLOUT;
((EpollEventLoop) eventLoop()).modify(this); ((EpollEventLoop) eventLoop()).modify(this);
} }
} }
@ -528,7 +528,11 @@ public final class EpollSocketChannel extends AbstractEpollChannel implements So
@Override @Override
void epollRdHupReady() { void epollRdHupReady() {
closeOnRead(pipeline()); if (isActive()) {
epollInReady();
} else {
closeOnRead(pipeline());
}
} }
@Override @Override