MEDIUM: poller: separate the wait time from the wake events
We have been abusing the do_poll()'s timeout for a while, making it zero
whenever there is some known activity. The problem this poses is that it
complicates activity diagnostic by incrementing the poll_exp field for
each known activity. It also requires extra computations that could be
avoided.
This change passes a "wake" argument to say that the poller must not
sleep. This simplifies the operations and allows one to differenciate
expirations from activity.
diff --git a/src/ev_epoll.c b/src/ev_epoll.c
index 039327d..6c09c04 100644
--- a/src/ev_epoll.c
+++ b/src/ev_epoll.c
@@ -103,7 +103,7 @@
/*
* Linux epoll() poller
*/
-REGPRM2 static void _do_poll(struct poller *p, int exp)
+REGPRM3 static void _do_poll(struct poller *p, int exp, int wake)
{
int status;
int fd;
@@ -147,7 +147,7 @@
thread_harmless_now();
/* now let's wait for polled events */
- wait_time = compute_poll_timeout(exp);
+ wait_time = wake ? 0 : compute_poll_timeout(exp);
tv_entering_poll();
activity_count_runtime();
do {
@@ -160,7 +160,7 @@
break;
if (timeout || !wait_time)
break;
- if (signal_queue_len)
+ if (signal_queue_len || wake)
break;
if (tick_isset(exp) && tick_is_expired(exp, now_ms))
break;