Skip to content

Commit

Permalink
Revert "ctrl: remove the unnecessary timer fd read"
Browse files Browse the repository at this point in the history
This reverts commit be161fe.

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 <[email protected]>
  • Loading branch information
yuanhanliu committed Dec 19, 2023
1 parent ebab503 commit 98ee880
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/ctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}
Expand Down

0 comments on commit 98ee880

Please sign in to comment.