From 98ee880c2b7e00a091f52d320972d64959620a25 Mon Sep 17 00:00:00 2001 From: Yuanhan Liu Date: Tue, 19 Dec 2023 12:02:44 +0800 Subject: [PATCH] Revert "ctrl: remove the unnecessary timer fd read" This reverts commit be161fec12d3ff946086e0e292f78e34d36e11e8. It's actually needed: as the ctrl epoll works in LT mode. We need to drain the fd, otherewise, the EPOLLIN event alarms all the time. Signed-off-by: Yuanhan Liu --- src/ctrl.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/ctrl.c b/src/ctrl.c index fdd0c1f..be47c99 100644 --- a/src/ctrl.c +++ b/src/ctrl.c @@ -45,6 +45,13 @@ static int ctrl_thread_create(void *(*func)(void *), void *arg, const char *name return 0; } +static void timeout_event_done(int fd) +{ + uint64_t expirations; + + read(fd, &expirations, sizeof(expirations)); +} + static int epfd = -1; #define MAX_EPOLL_EVENT 16 @@ -62,6 +69,9 @@ static void *poll_ctrl_event(void *ignored) for (i = 0; i < ret; i++) { ctrl_event = events[i].data.ptr; + if (ctrl_event->timeout_event) + timeout_event_done(ctrl_event->fd); + if (ctrl_event->cb) ctrl_event->cb(ctrl_event); }