diff options
author | Graeme Gill <graeme2@argyllcms.com> | 2011-09-10 15:47:05 +0200 |
---|---|---|
committer | Peter Stuge <peter@stuge.se> | 2011-09-22 11:25:29 +0200 |
commit | 6696512aade99bb15d6792af90ae329af270eba6 (patch) | |
tree | 9137a1fdd3b78ace9d6b49902054598b57e1b3e7 /libusb/libusb-1.0.def | |
parent | cfee5446cdb2974c1e90c7c379a365c495975aef (diff) | |
download | libusb-6696512aade99bb15d6792af90ae329af270eba6.tar.gz |
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-1.0.def')
-rw-r--r-- | libusb/libusb-1.0.def | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/libusb/libusb-1.0.def b/libusb/libusb-1.0.def index 9cdbc5f..4eef912 100644 --- a/libusb/libusb-1.0.def +++ b/libusb/libusb-1.0.def @@ -62,10 +62,14 @@ EXPORTS libusb_get_string_descriptor_ascii@16 = libusb_get_string_descriptor_ascii libusb_handle_events libusb_handle_events@4 = libusb_handle_events + libusb_handle_events_completed + libusb_handle_events_completed@8 = libusb_handle_events_completed libusb_handle_events_locked libusb_handle_events_locked@8 = libusb_handle_events_locked libusb_handle_events_timeout libusb_handle_events_timeout@8 = libusb_handle_events_timeout + libusb_handle_events_timeout_completed + libusb_handle_events_timeout_completed@12 = libusb_handle_events_timeout_completed libusb_init libusb_init@4 = libusb_init libusb_interrupt_transfer |