| 72 | } |
| 73 | |
| 74 | static int aeApiAddEvent(aeEventLoop *eventLoop, int fd, int mask) { |
| 75 | aeApiState *state = eventLoop->apidata; |
| 76 | struct epoll_event ee = {0}; /* avoid valgrind warning */ |
| 77 | /* If the fd was already monitored for some event, we need a MOD |
| 78 | * operation. Otherwise we need an ADD operation. */ |
| 79 | int op = eventLoop->events[fd].mask == AE_NONE ? |
| 80 | EPOLL_CTL_ADD : EPOLL_CTL_MOD; |
| 81 | |
| 82 | ee.events = 0; |
| 83 | mask |= eventLoop->events[fd].mask; /* Merge old events */ |
| 84 | if (mask & AE_READABLE) ee.events |= EPOLLIN; |
| 85 | if (mask & AE_WRITABLE) ee.events |= EPOLLOUT; |
| 86 | ee.data.fd = fd; |
| 87 | if (epoll_ctl(state->epfd,op,fd,&ee) == -1) return -1; |
| 88 | return 0; |
| 89 | } |
| 90 | |
| 91 | static void aeApiDelEvent(aeEventLoop *eventLoop, int fd, int delmask) { |
| 92 | aeApiState *state = eventLoop->apidata; |
no test coverage detected