use select in scheduler

This commit is contained in:
DanyLE 2022-08-30 17:36:19 +02:00
parent e35c8b7a6f
commit bf9cd3f1ca

View File

@ -295,7 +295,7 @@ static void print_static_info(bst_node_t *node, void **args, int argc)
} }
static void *statistic(antd_scheduler_t *scheduler) static void *statistic(antd_scheduler_t *scheduler)
{ {
fd_set fd_out; struct pollfd pfd;
int ret; int ret;
char buffer[MAX_FIFO_NAME_SZ]; char buffer[MAX_FIFO_NAME_SZ];
void *argc[2]; void *argc[2];
@ -316,9 +316,9 @@ static void *statistic(antd_scheduler_t *scheduler)
} }
argc[0] = buffer; argc[0] = buffer;
argc[1] = &scheduler->stat_fd; argc[1] = &scheduler->stat_fd;
FD_ZERO(&fd_out); pfd.fd = scheduler->stat_fd;
FD_SET(scheduler->stat_fd, &fd_out); pfd.events = POLLOUT;
ret = select(scheduler->stat_fd + 1, NULL, &fd_out, NULL, NULL); ret = poll(&pfd, 1, -1);
switch (ret) switch (ret)
{ {
case -1: case -1:
@ -330,7 +330,7 @@ static void *statistic(antd_scheduler_t *scheduler)
break; break;
// we have data // we have data
default: default:
if (FD_ISSET(scheduler->stat_fd, &fd_out)) if (pfd.revents & POLLOUT)
{ {
if (scheduler->pending_task > 0) if (scheduler->pending_task > 0)
{ {