aboutsummaryrefslogtreecommitdiffstats
path: root/libusb/libusb.h
diff options
context:
space:
mode:
authorGraeme Gill <graeme2@argyllcms.com>2011-09-10 15:47:05 +0200
committerPeter Stuge <peter@stuge.se>2011-09-22 11:25:29 +0200
commit6696512aade99bb15d6792af90ae329af270eba6 (patch)
tree9137a1fdd3b78ace9d6b49902054598b57e1b3e7 /libusb/libusb.h
parentcfee5446cdb2974c1e90c7c379a365c495975aef (diff)
downloadandroid_external_libusbx-6696512aade99bb15d6792af90ae329af270eba6.tar.gz
android_external_libusbx-6696512aade99bb15d6792af90ae329af270eba6.tar.bz2
android_external_libusbx-6696512aade99bb15d6792af90ae329af270eba6.zip
Fix #56 race condition causing delayed completion of sync transfers
The sync API had a race where it would check a condition to know if it needed to call a libusb_handle_events() function. However, the check was done outside of the lock that is held while the condition is set, so another thread could completely serve whatever was needed to make the condition true between it being checked and the event handler being called. This situation would be detected after a libusb-internal timeout of 60 seconds, after which the transfer would be completed without error, but with significant delay. Original patch at http://marc.info/?l=libusb-devel&m=127252114815709 Changes by Hans de Goede: - Renamed the "race-proof" functions from libusb_handle_events*_check() to libusb_handle_events*_completed() - Drop r = 0 setting in libusb_handle_events_timeout_completed() (to make both completed checking cases identical flow wise) Signed-off-by: Hans de Goede <hdegoede@redhat.com> [stuge: Simplify libusb_handle_events_timeout() change with a goto] [pbatard: Fix _handle_events_timeout() and _completed() definitions]
Diffstat (limited to 'libusb/libusb.h')
-rw-r--r--libusb/libusb.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/libusb/libusb.h b/libusb/libusb.h
index 425ad0e..3b7f92a 100644
--- a/libusb/libusb.h
+++ b/libusb/libusb.h
@@ -1315,7 +1315,10 @@ int LIBUSB_CALL libusb_wait_for_event(libusb_context *ctx, struct timeval *tv);
int LIBUSB_CALL libusb_handle_events_timeout(libusb_context *ctx,
struct timeval *tv);
+int LIBUSB_CALL libusb_handle_events_timeout_completed(libusb_context *ctx,
+ struct timeval *tv, int *completed);
int LIBUSB_CALL libusb_handle_events(libusb_context *ctx);
+int LIBUSB_CALL libusb_handle_events_completed(libusb_context *ctx, int *completed);
int LIBUSB_CALL libusb_handle_events_locked(libusb_context *ctx,
struct timeval *tv);
int LIBUSB_CALL libusb_pollfds_handle_timeouts(libusb_context *ctx);