summaryrefslogtreecommitdiff
path: root/ot_event.c
diff options
context:
space:
mode:
Diffstat (limited to 'ot_event.c')
-rw-r--r--ot_event.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/ot_event.c b/ot_event.c
index 1542bf5..8f55817 100644
--- a/ot_event.c
+++ b/ot_event.c
@@ -71,6 +71,10 @@ int event_add(int fd, int what, uint32_t generation) { return event_ctl(EPOLL_CT
71int event_modify(int fd, int what, uint32_t generation) { return event_ctl(EPOLL_CTL_MOD, fd, what, generation); } 71int event_modify(int fd, int what, uint32_t generation) { return event_ctl(EPOLL_CTL_MOD, fd, what, generation); }
72int event_del(int fd) { return epoll_ctl(g_epoll, EPOLL_CTL_DEL, fd, NULL); } 72int 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 */
76int event_close(int fd) { return close(fd); }
77
74int event_wait(ot_event *out, int max, int timeout_ms) { 78int 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
171int event_modify(int fd, int what, uint32_t generation) { return event_change(fd, what, generation, 0); } 175int event_modify(int fd, int what, uint32_t generation) { return event_change(fd, what, generation, 0); }
172int event_del(int fd) { return event_change(fd, 0, 0, 1); } 176int event_del(int fd) { return event_change(fd, 0, 0, 1); }
173 177
178/* Closing a descriptor removes every kevent that references it */
179int event_close(int fd) { return close(fd); }
180
174int event_wait(ot_event *out, int max, int timeout_ms) { 181int 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 */
323int event_close(int fd) {
324 event_del(fd);
325 return close(fd);
326}
327
314int event_wait(ot_event *out, int max, int timeout_ms) { 328int event_wait(ot_event *out, int max, int timeout_ms) {
315 int ready, found = 0, i; 329 int ready, found = 0, i;
316 330