diff --git a/Scheduler/Scheduler.cc b/Scheduler/Scheduler.cc index 41708511e832a07ebdfef46756c4062709e9c221..1afc018e960aa63fc1babd2ea36fa2d53b5c9acb 100644 --- a/Scheduler/Scheduler.cc +++ b/Scheduler/Scheduler.cc @@ -104,12 +104,20 @@ prefix_ void senf::Scheduler::unregisterSignal(unsigned signal) prefix_ void senf::Scheduler::do_add(int fd, FdCallback const & cb, int eventMask) { + if (eventMask == 0) + return; + FdTable::iterator i (fdTable_.find(fd)); int action (EPOLL_CTL_MOD); if (i == fdTable_.end()) { action = EPOLL_CTL_ADD; i = fdTable_.insert(std::make_pair(fd, EventSpec())).first; } + if (i->second.epollMask() == 0) { + action = EPOLL_CTL_ADD; + fdErase_.erase( std::remove(fdErase_.begin(), fdErase_.end(), unsigned(fd)), + fdErase_.end() ); + } if (eventMask & EV_READ) i->second.cb_read = cb; if (eventMask & EV_PRIO) i->second.cb_prio = cb; @@ -133,6 +141,9 @@ prefix_ void senf::Scheduler::do_add(int fd, FdCallback const & cb, int eventMas prefix_ void senf::Scheduler::do_remove(int fd, int eventMask) { + if (eventMask == 0) + return; + FdTable::iterator i (fdTable_.find(fd)); if (i == fdTable_.end()) return;