From: g0dil Date: Thu, 15 Nov 2007 13:27:15 +0000 (+0000) Subject: Scheduler: BUGFIX: check fdErase_ when (re-)adding a filedescriptor X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=f358cbf3cb00759bc8e55ab13d4b50040c49b133;p=senf.git Scheduler: BUGFIX: check fdErase_ when (re-)adding a filedescriptor git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@521 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/Scheduler/Scheduler.cc b/Scheduler/Scheduler.cc index 4170851..1afc018 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;