diff options
Diffstat (limited to 'ot_event.c')
| -rw-r--r-- | ot_event.c | 14 |
1 files changed, 14 insertions, 0 deletions
| @@ -71,6 +71,10 @@ int event_add(int fd, int what, uint32_t generation) { return event_ctl(EPOLL_CT | |||
| 71 | int event_modify(int fd, int what, uint32_t generation) { return event_ctl(EPOLL_CTL_MOD, fd, what, generation); } | 71 | int event_modify(int fd, int what, uint32_t generation) { return event_ctl(EPOLL_CTL_MOD, fd, what, generation); } |
| 72 | int event_del(int fd) { return epoll_ctl(g_epoll, EPOLL_CTL_DEL, fd, NULL); } | 72 | int event_del(int fd) { return epoll_ctl(g_epoll, EPOLL_CTL_DEL, fd, NULL); } |
| 73 | 73 | ||
| 74 | /* A descriptor leaves the interest list when the last reference to its open | ||
| 75 | file description is closed, and the tracker never duplicates one */ | ||
| 76 | int event_close(int fd) { return close(fd); } | ||
| 77 | |||
| 74 | int event_wait(ot_event *out, int max, int timeout_ms) { | 78 | int event_wait(ot_event *out, int max, int timeout_ms) { |
| 75 | int count, i; | 79 | int count, i; |
| 76 | 80 | ||
| @@ -171,6 +175,9 @@ int event_add(int fd, int what, uint32_t generation) { return event_change(fd, w | |||
| 171 | int event_modify(int fd, int what, uint32_t generation) { return event_change(fd, what, generation, 0); } | 175 | int event_modify(int fd, int what, uint32_t generation) { return event_change(fd, what, generation, 0); } |
| 172 | int event_del(int fd) { return event_change(fd, 0, 0, 1); } | 176 | int event_del(int fd) { return event_change(fd, 0, 0, 1); } |
| 173 | 177 | ||
| 178 | /* Closing a descriptor removes every kevent that references it */ | ||
| 179 | int event_close(int fd) { return close(fd); } | ||
| 180 | |||
| 174 | int event_wait(ot_event *out, int max, int timeout_ms) { | 181 | int event_wait(ot_event *out, int max, int timeout_ms) { |
| 175 | struct timespec timeout; | 182 | struct timespec timeout; |
| 176 | struct timespec *deadline = NULL; | 183 | struct timespec *deadline = NULL; |
| @@ -311,6 +318,13 @@ int event_del(int fd) { | |||
| 311 | return 0; | 318 | return 0; |
| 312 | } | 319 | } |
| 313 | 320 | ||
| 321 | /* Nothing here lives in the kernel, so the entry has to come out by hand | ||
| 322 | before the descriptor goes, or poll reports POLLNVAL for it forever */ | ||
| 323 | int event_close(int fd) { | ||
| 324 | event_del(fd); | ||
| 325 | return close(fd); | ||
| 326 | } | ||
| 327 | |||
| 314 | int event_wait(ot_event *out, int max, int timeout_ms) { | 328 | int event_wait(ot_event *out, int max, int timeout_ms) { |
| 315 | int ready, found = 0, i; | 329 | int ready, found = 0, i; |
| 316 | 330 | ||
