- /** Use oneshot so that the system removes the writeable
- * status for us and saves us a call.
- */
- struct epoll_event ev;
- memset(&ev,0,sizeof(struct epoll_event));
- ev.events = EPOLLOUT;
- ev.data.fd = eh->GetFd();
- epoll_ctl(EngineHandle, EPOLL_CTL_MOD, eh->GetFd(), &ev);
+ unsigned old_events = mask_to_epoll(old_mask);
+ unsigned new_events = mask_to_epoll(new_mask);
+ if (old_events != new_events)
+ {
+ // ok, we actually have something to tell the kernel about
+ struct epoll_event ev;
+ memset(&ev, 0, sizeof(ev));
+ ev.events = new_events;
+ ev.data.ptr = static_cast<void*>(eh);
+ epoll_ctl(EngineHandle, EPOLL_CTL_MOD, eh->GetFd(), &ev);
+ }