From 95fd9a4ae2717a73bc446b29a87ad5bc9f00317e Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Fri, 30 Oct 2026 02:35:32 +0100 Subject: Reduce number of per connection sys calls --- ot_event.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'ot_event.c') 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 int event_modify(int fd, int what, uint32_t generation) { return event_ctl(EPOLL_CTL_MOD, fd, what, generation); } int event_del(int fd) { return epoll_ctl(g_epoll, EPOLL_CTL_DEL, fd, NULL); } +/* A descriptor leaves the interest list when the last reference to its open + file description is closed, and the tracker never duplicates one */ +int event_close(int fd) { return close(fd); } + int event_wait(ot_event *out, int max, int timeout_ms) { int count, i; @@ -171,6 +175,9 @@ int event_add(int fd, int what, uint32_t generation) { return event_change(fd, w int event_modify(int fd, int what, uint32_t generation) { return event_change(fd, what, generation, 0); } int event_del(int fd) { return event_change(fd, 0, 0, 1); } +/* Closing a descriptor removes every kevent that references it */ +int event_close(int fd) { return close(fd); } + int event_wait(ot_event *out, int max, int timeout_ms) { struct timespec timeout; struct timespec *deadline = NULL; @@ -311,6 +318,13 @@ int event_del(int fd) { return 0; } +/* Nothing here lives in the kernel, so the entry has to come out by hand + before the descriptor goes, or poll reports POLLNVAL for it forever */ +int event_close(int fd) { + event_del(fd); + return close(fd); +} + int event_wait(ot_event *out, int max, int timeout_ms) { int ready, found = 0, i; -- cgit v1.3