projects
/
platform
/
upstream
/
libusb.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
5ad79b3
)
round up poll timeout
author
Daniel Drake
<dsd@gentoo.org>
Sun, 15 Jun 2008 20:23:29 +0000
(15:23 -0500)
committer
Daniel Drake
<dsd@gentoo.org>
Sun, 15 Jun 2008 20:23:29 +0000
(15:23 -0500)
Pointed out by Richard Röjfors, otherwise we end up busy-looping with
a poll() timeout of 0.
libusb/io.c
patch
|
blob
|
history
diff --git
a/libusb/io.c
b/libusb/io.c
index
4e85bdf
..
f659d24
100644
(file)
--- 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);