summaryrefslogtreecommitdiff
path: root/libusb
diff options
context:
space:
mode:
authorDaniel Drake <dsd@gentoo.org>2008-06-15 15:23:29 -0500
committerDaniel Drake <dsd@gentoo.org>2008-06-15 15:23:29 -0500
commit217534e4b396081e038ee5f94c813d1668963673 (patch)
tree838a78bdeffec1d796a54feb3b56b44ccc7cb14e /libusb
parent5ad79b324bc5e11a75a585398a1e81c26f05e758 (diff)
downloadlibusb-217534e4b396081e038ee5f94c813d1668963673.tar.gz
round up poll timeout
Pointed out by Richard Röjfors, otherwise we end up busy-looping with a poll() timeout of 0.
Diffstat (limited to 'libusb')
-rw-r--r--libusb/io.c5
1 files changed, 5 insertions, 0 deletions
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);