[MAJOR] replaced all timeouts with struct timeval
The timeout functions were difficult to manipulate because they were
rounding results to the millisecond. Thus, it was difficult to compare
and to check what expired and what did not. Also, the comparison
functions were heavy with multiplies and divides by 1000. Now, all
timeouts are stored in timevals, reducing the number of operations
for updates and leading to cleaner and more efficient code.
diff --git a/src/ev_epoll.c b/src/ev_epoll.c
index b484499..a867e8d 100644
--- a/src/ev_epoll.c
+++ b/src/ev_epoll.c
@@ -220,16 +220,22 @@
/*
* epoll() poller
*/
-REGPRM2 static void _do_poll(struct poller *p, int wait_time)
+REGPRM2 static void _do_poll(struct poller *p, struct timeval *exp)
{
int status;
int fd;
int count;
+ int wait_time;
if (likely(nbchanges))
fd_flush_changes();
/* now let's wait for events */
+ if (tv_isset(exp))
+ wait_time = tv_ms_remain(&now, exp);
+ else
+ wait_time = -1;
+
status = epoll_wait(epoll_fd, epoll_events, maxfd, wait_time);
tv_now(&now);