MINOR: fd: centralize poll timeout computation in compute_poll_timeout()
The 4 pollers all contain the same code used to compute the poll timeout.
This is pointless, let's centralize this into fd.h. This also gets rid of
the useless SCHEDULER_RESOLUTION macro which used to work arond a very old
linux 2.2 bug causing select() to wake up slightly before the timeout.
diff --git a/src/ev_kqueue.c b/src/ev_kqueue.c
index e2f04f7..3d21cb0 100644
--- a/src/ev_kqueue.c
+++ b/src/ev_kqueue.c
@@ -129,23 +129,10 @@
}
fd_nbupdt = 0;
- delta_ms = 0;
-
- if (!exp) {
- delta_ms = MAX_DELAY_MS;
- timeout.tv_sec = (MAX_DELAY_MS / 1000);
- timeout.tv_nsec = (MAX_DELAY_MS % 1000) * 1000000;
- }
- else if (!tick_is_expired(exp, now_ms)) {
- delta_ms = TICKS_TO_MS(tick_remain(now_ms, exp)) + 1;
- if (delta_ms > MAX_DELAY_MS)
- delta_ms = MAX_DELAY_MS;
- timeout.tv_sec = (delta_ms / 1000);
- timeout.tv_nsec = (delta_ms % 1000) * 1000000;
- }
- else
- activity[tid].poll_exp++;
-
+ /* now let's wait for events */
+ delta_ms = compute_poll_timeout(exp);
+ timeout.tv_sec = (delta_ms / 1000);
+ timeout.tv_nsec = (delta_ms % 1000) * 1000000;
fd = global.tune.maxpollevents;
gettimeofday(&before_poll, NULL);
status = kevent(kqueue_fd[tid], // int kq