diff options
author | hselasky <hselasky@FreeBSD.org> | 2012-06-12 07:28:25 +0000 |
---|---|---|
committer | hselasky <hselasky@FreeBSD.org> | 2012-06-12 07:28:25 +0000 |
commit | 4dd0cbb180887654865f48b1afa9250ed68d17c7 (patch) | |
tree | f5c627ab0a90aceb65f1e3857c3d3c2e65b18b94 /lib/libusb/libusb10_io.c | |
parent | fb4fac5af865cb1696d7d1848144bb8828d5413d (diff) | |
download | FreeBSD-src-4dd0cbb180887654865f48b1afa9250ed68d17c7.zip FreeBSD-src-4dd0cbb180887654865f48b1afa9250ed68d17c7.tar.gz |
LibUSB v1.0 API compiliance and bugfixes.
- Use CLOCK_MONOTONIC instead of CLOCK_REALTIME, because CLOCK_MONOTONIC
does not wrap into negative in near future. This fixes any potential
problems using "pthread_cond_timedwait()".
- Fix a bug where the "libusb_wait_for_event()" function computes an
absolute timeout instead of a relative timeout. USB transfers do
not depend on this timeout value.
- Add dependency towards LibPthread to Makefile, because LibUSB v1.0
needs this library to function correctly.
MFC after: 1 week
Diffstat (limited to 'lib/libusb/libusb10_io.c')
-rw-r--r-- | lib/libusb/libusb10_io.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/libusb/libusb10_io.c b/lib/libusb/libusb10_io.c index 63f833a..302fdb8 100644 --- a/lib/libusb/libusb10_io.c +++ b/lib/libusb/libusb10_io.c @@ -307,12 +307,16 @@ libusb_wait_for_event(libusb_context *ctx, struct timeval *tv) &ctx->ctx_lock); return (0); } - err = clock_gettime(CLOCK_REALTIME, &ts); + err = clock_gettime(CLOCK_MONOTONIC, &ts); if (err < 0) return (LIBUSB_ERROR_OTHER); - ts.tv_sec = tv->tv_sec; - ts.tv_nsec = tv->tv_usec * 1000; + /* + * The "tv" arguments points to a relative time structure and + * not an absolute time structure. + */ + ts.tv_sec += tv->tv_sec; + ts.tv_nsec += tv->tv_usec * 1000; if (ts.tv_nsec >= 1000000000) { ts.tv_nsec -= 1000000000; ts.tv_sec++; |