diff --git a/coroio/backends/epoll.cpp b/coroio/backends/epoll.cpp index ef86676..15f1f33 100644 --- a/coroio/backends/epoll.cpp +++ b/coroio/backends/epoll.cpp @@ -60,7 +60,7 @@ void TEPoll::Poll() { bool change = false; bool newEv = false; if (ch.Handle) { - newEv = !!ev.Read && !!ev.Write && !!ev.RHup; + newEv = ev.Empty(); if (ch.Type & TEvent::READ) { eev.events |= EPOLLIN; change |= ev.Read != ch.Handle; @@ -101,6 +101,7 @@ void TEPoll::Poll() { throw std::system_error(errno, std::generic_category(), "epoll_ctl"); } } else if (!eev.events) { + ev.Reset(); if (epoll_ctl(Fd_, EPOLL_CTL_DEL, fd, nullptr) < 0) { if (!(errno == EBADF || errno == ENOENT)) { // closed descriptor after TSocket -> close throw std::system_error(errno, std::generic_category(), "epoll_ctl"); diff --git a/coroio/base.hpp b/coroio/base.hpp index b719840..eff278b 100644 --- a/coroio/base.hpp +++ b/coroio/base.hpp @@ -28,6 +28,16 @@ struct THandlePair { THandle Read = {}; THandle Write = {}; THandle RHup = {}; + + bool Empty() const { + return !Read && !Write && !RHup; + } + + void Reset() { + Read = {}; + Write = {}; + RHup = {}; + } }; struct TEvent {