From 96a25ae6a2d4f63f1df483cd3d49b779175031b0 Mon Sep 17 00:00:00 2001 From: Niels Provos Date: Sun, 19 Sep 2004 22:38:34 +0000 Subject: [PATCH] when converting usec to msec round up; so that libevent does not spin until the time conversion has caught up; from Aaron Hopkins svn:r121 --- devpoll.c | 2 +- epoll.c | 2 +- poll.c | 2 +- rtsig.c | 3 ++- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/devpoll.c b/devpoll.c index 5fafdf54..183db85d 100644 --- a/devpoll.c +++ b/devpoll.c @@ -177,7 +177,7 @@ devpoll_dispatch(void *arg, struct timeval *tv) if (evsignal_deliver(&devpollop->evsigmask) == -1) return (-1); - timeout = tv->tv_sec * 1000 + tv->tv_usec / 1000; + timeout = tv->tv_sec * 1000 + (tv->tv_usec + 999) / 1000; dvp.dp_fds = devpollop->events; dvp.dp_nfds = devpollop->nevents; diff --git a/epoll.c b/epoll.c index be7e2d41..9924d0fb 100644 --- a/epoll.c +++ b/epoll.c @@ -189,7 +189,7 @@ epoll_dispatch(void *arg, struct timeval *tv) if (evsignal_deliver(&epollop->evsigmask) == -1) return (-1); - timeout = tv->tv_sec * 1000 + tv->tv_usec / 1000; + timeout = tv->tv_sec * 1000 + (tv->tv_usec + 999) / 1000; res = epoll_wait(epollop->epfd, events, epollop->nevents, timeout); if (evsignal_recalc(&epollop->evsigmask) == -1) diff --git a/poll.c b/poll.c index 773e4d1b..bba594d4 100644 --- a/poll.c +++ b/poll.c @@ -166,7 +166,7 @@ poll_dispatch(void *arg, struct timeval *tv) if (evsignal_deliver(&pop->evsigmask) == -1) return (-1); - sec = tv->tv_sec * 1000 + tv->tv_usec / 1000; + sec = tv->tv_sec * 1000 + (tv->tv_usec + 999) / 1000; res = poll(pop->event_set, nfds, sec); if (evsignal_recalc(&pop->evsigmask) == -1) diff --git a/rtsig.c b/rtsig.c index 960715f3..59d1ceaa 100644 --- a/rtsig.c +++ b/rtsig.c @@ -368,7 +368,8 @@ rtsig_dispatch(void *arg, struct timeval *tv) if (!op->cur) return (0); - res = poll(op->poll, op->cur, tv->tv_sec * 1000 + tv->tv_usec / 1000); + res = poll(op->poll, op->cur, tv->tv_sec * 1000 + + (tv->tv_usec + 999) / 1000); if (res < 0) return (-1); -- 2.40.0