mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-01-06 20:29:48 +00:00
[BUG] fix null timeouts in *poll-based pollers
Introduction of timeval timers broke *poll-based pollers, because the call to tv_ms_remain may return 0 while the event is not elapsed yet. Now we carefully check for those cases and round the result up by 1 ms.
This commit is contained in:
parent
aff694f3b6
commit
bdefc513a0
@ -231,10 +231,12 @@ REGPRM2 static void _do_poll(struct poller *p, struct timeval *exp)
|
|||||||
fd_flush_changes();
|
fd_flush_changes();
|
||||||
|
|
||||||
/* now let's wait for events */
|
/* now let's wait for events */
|
||||||
if (tv_isset(exp))
|
if (tv_iseternity(exp))
|
||||||
wait_time = tv_ms_remain(&now, exp);
|
|
||||||
else
|
|
||||||
wait_time = -1;
|
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);
|
status = epoll_wait(epoll_fd, epoll_events, maxfd, wait_time);
|
||||||
tv_now(&now);
|
tv_now(&now);
|
||||||
|
@ -124,10 +124,12 @@ REGPRM2 static void _do_poll(struct poller *p, struct timeval *exp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* now let's wait for events */
|
/* now let's wait for events */
|
||||||
if (tv_isset(exp))
|
if (tv_iseternity(exp))
|
||||||
wait_time = tv_ms_remain(&now, exp);
|
|
||||||
else
|
|
||||||
wait_time = -1;
|
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);
|
status = poll(poll_events, nbfd, wait_time);
|
||||||
tv_now(&now);
|
tv_now(&now);
|
||||||
|
@ -380,10 +380,12 @@ REGPRM2 static void _do_poll(struct poller *p, struct timeval *exp)
|
|||||||
wait_time = 0;
|
wait_time = 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (tv_isset(exp))
|
if (tv_iseternity(exp))
|
||||||
wait_time = tv_ms_remain(&now, exp);
|
|
||||||
else
|
|
||||||
wait_time = -1;
|
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 */
|
/* now let's wait for real events */
|
||||||
|
Loading…
Reference in New Issue
Block a user