From 217534e4b396081e038ee5f94c813d1668963673 Mon Sep 17 00:00:00 2001 From: Daniel Drake Date: Sun, 15 Jun 2008 15:23:29 -0500 Subject: [PATCH] round up poll timeout MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Pointed out by Richard Röjfors, otherwise we end up busy-looping with a poll() timeout of 0. --- libusb/io.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libusb/io.c b/libusb/io.c index 4e85bdf..f659d24 100644 --- a/libusb/io.c +++ b/libusb/io.c @@ -1335,6 +1335,11 @@ static int handle_events(struct timeval *tv) pthread_mutex_unlock(&pollfds_lock); timeout_ms = (tv->tv_sec * 1000) + (tv->tv_usec / 1000); + + /* round up to next millisecond */ + if (tv->tv_usec % 1000) + timeout_ms++; + usbi_dbg("poll() %d fds with timeout in %dms", nfds, timeout_ms); r = poll(fds, nfds, timeout_ms); usbi_dbg("poll() returned %d", r); -- 2.7.4