| 107 | } |
| 108 | |
| 109 | static int aeApiPoll(aeEventLoop *eventLoop, struct timeval *tvp) { |
| 110 | aeApiState *state = eventLoop->apidata; |
| 111 | int retval, numevents = 0; |
| 112 | |
| 113 | retval = epoll_wait(state->epfd,state->events,eventLoop->setsize, |
| 114 | tvp ? (tvp->tv_sec*1000 + (tvp->tv_usec + 999)/1000) : -1); |
| 115 | if (retval > 0) { |
| 116 | int j; |
| 117 | |
| 118 | numevents = retval; |
| 119 | for (j = 0; j < numevents; j++) { |
| 120 | int mask = 0; |
| 121 | struct epoll_event *e = state->events+j; |
| 122 | |
| 123 | if (e->events & EPOLLIN) mask |= AE_READABLE; |
| 124 | if (e->events & EPOLLOUT) mask |= AE_WRITABLE; |
| 125 | if (e->events & EPOLLERR) mask |= AE_WRITABLE|AE_READABLE; |
| 126 | if (e->events & EPOLLHUP) mask |= AE_WRITABLE|AE_READABLE; |
| 127 | eventLoop->fired[j].fd = e->data.fd; |
| 128 | eventLoop->fired[j].mask = mask; |
| 129 | } |
| 130 | } |
| 131 | return numevents; |
| 132 | } |
| 133 | |
| 134 | static char *aeApiName(void) { |
| 135 | return "epoll"; |
no test coverage detected