when converting usec to msec round up; so that libevent does not spin until

the time conversion has caught up; from Aaron Hopkins <aaron at die.net>


svn:r121
This commit is contained in:
Niels Provos 2004-09-19 22:38:34 +00:00
parent fa6c304d9e
commit 96a25ae6a2
4 changed files with 5 additions and 4 deletions

View File

@ -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;

View File

@ -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)

2
poll.c
View File

@ -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)

View File

@ -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);