Skip to content
Browse files

Fixed a lame epoll issue

  • Loading branch information...
1 parent 163f4b8 commit 67669f0032b27d9c434bc91b1cf5b199e9077fd2 @antirez committed Dec 16, 2009
Showing with 3 additions and 0 deletions.
  1. +3 −0 ae_epoll.c
View
3 ae_epoll.c
@@ -29,10 +29,13 @@ static void aeApiFree(aeEventLoop *eventLoop) {
static int aeApiAddEvent(aeEventLoop *eventLoop, int fd, int mask) {
aeApiState *state = eventLoop->apidata;
struct epoll_event ee;
+ /* If the fd was already monitored for some event, we need a MOD
+ * operation. Otherwise we need an ADD operation. */
int op = eventLoop->events[fd].mask == AE_NONE ?
EPOLL_CTL_ADD : EPOLL_CTL_MOD;
ee.events = 0;
+ mask |= eventLoop->events[fd].mask; /* Merge old events */
if (mask & AE_READABLE) ee.events |= EPOLLIN;
if (mask & AE_WRITABLE) ee.events |= EPOLLOUT;
if (mask & AE_EXCEPTION) ee.events |= EPOLLPRI;

0 comments on commit 67669f0

Please sign in to comment.
Something went wrong with that request. Please try again.