From bf9cd3f1ca33673461474ab56aa486878fbd52e1 Mon Sep 17 00:00:00 2001 From: DanyLE Date: Tue, 30 Aug 2022 17:36:19 +0200 Subject: [PATCH] use select in scheduler --- lib/scheduler.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/scheduler.c b/lib/scheduler.c index 5400b7d..0cc2c47 100644 --- a/lib/scheduler.c +++ b/lib/scheduler.c @@ -295,7 +295,7 @@ static void print_static_info(bst_node_t *node, void **args, int argc) } static void *statistic(antd_scheduler_t *scheduler) { - fd_set fd_out; + struct pollfd pfd; int ret; char buffer[MAX_FIFO_NAME_SZ]; void *argc[2]; @@ -316,9 +316,9 @@ static void *statistic(antd_scheduler_t *scheduler) } argc[0] = buffer; argc[1] = &scheduler->stat_fd; - FD_ZERO(&fd_out); - FD_SET(scheduler->stat_fd, &fd_out); - ret = select(scheduler->stat_fd + 1, NULL, &fd_out, NULL, NULL); + pfd.fd = scheduler->stat_fd; + pfd.events = POLLOUT; + ret = poll(&pfd, 1, -1); switch (ret) { case -1: @@ -330,7 +330,7 @@ static void *statistic(antd_scheduler_t *scheduler) break; // we have data default: - if (FD_ISSET(scheduler->stat_fd, &fd_out)) + if (pfd.revents & POLLOUT) { if (scheduler->pending_task > 0) {