Skip to content

Commit

Permalink
lib: Fix usec comparison in timeout_update_next
Browse files Browse the repository at this point in the history
When tv_usec is exactly 1000000, call to kevent() will fail
because tv_sec does not get incremented.

Found by Adrian Gonzalez <adrianglz@globalpc.net>
  • Loading branch information
cmouse committed Feb 13, 2018
1 parent e0dae5d commit d600de9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/ioloop.c
Expand Up @@ -232,7 +232,7 @@ static void timeout_update_next(struct timeout *timeout, struct timeval *tv_now)
timeout->next_run.tv_sec += timeout->msecs/1000;
timeout->next_run.tv_usec += (timeout->msecs%1000)*1000;

if (timeout->next_run.tv_usec > 1000000) {
if (timeout->next_run.tv_usec >= 1000000) {
timeout->next_run.tv_sec++;
timeout->next_run.tv_usec -= 1000000;
}
Expand Down

0 comments on commit d600de9

Please sign in to comment.