mirror of
https://github.com/lxsang/ant-http
synced 2024-11-18 01:08:21 +01:00
use select in scheduler
This commit is contained in:
parent
e35c8b7a6f
commit
bf9cd3f1ca
@ -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)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user