diff --git a/src/ev_epoll.c b/src/ev_epoll.c index a867e8dc3..d313d5690 100644 --- a/src/ev_epoll.c +++ b/src/ev_epoll.c @@ -231,10 +231,12 @@ REGPRM2 static void _do_poll(struct poller *p, struct timeval *exp) fd_flush_changes(); /* now let's wait for events */ - if (tv_isset(exp)) - wait_time = tv_ms_remain(&now, exp); - else + if (tv_iseternity(exp)) wait_time = -1; + else if (tv_isge(&now, exp)) + wait_time = 0; + else + wait_time = __tv_ms_elapsed(&now, exp) + 1; status = epoll_wait(epoll_fd, epoll_events, maxfd, wait_time); tv_now(&now); diff --git a/src/ev_poll.c b/src/ev_poll.c index 3c97707cc..0166bd6ae 100644 --- a/src/ev_poll.c +++ b/src/ev_poll.c @@ -124,10 +124,12 @@ REGPRM2 static void _do_poll(struct poller *p, struct timeval *exp) } /* now let's wait for events */ - if (tv_isset(exp)) - wait_time = tv_ms_remain(&now, exp); - else + if (tv_iseternity(exp)) wait_time = -1; + else if (tv_isge(&now, exp)) + wait_time = 0; + else + wait_time = __tv_ms_elapsed(&now, exp) + 1; status = poll(poll_events, nbfd, wait_time); tv_now(&now); diff --git a/src/ev_sepoll.c b/src/ev_sepoll.c index 516c0f592..3e25866f8 100644 --- a/src/ev_sepoll.c +++ b/src/ev_sepoll.c @@ -380,10 +380,12 @@ REGPRM2 static void _do_poll(struct poller *p, struct timeval *exp) wait_time = 0; } else { - if (tv_isset(exp)) - wait_time = tv_ms_remain(&now, exp); - else + if (tv_iseternity(exp)) wait_time = -1; + else if (tv_isge(&now, exp)) + wait_time = 0; + else + wait_time = __tv_ms_elapsed(&now, exp) + 1; } /* now let's wait for real events */