summaryrefslogtreecommitdiff
path: root/libusb/io.c
diff options
context:
space:
mode:
authorDaniel Drake <dsd@gentoo.org>2008-05-25 22:59:09 +0100
committerDaniel Drake <dsd@gentoo.org>2008-05-25 22:59:09 +0100
commit4cd249388e4ed2ca03f1263984ab67df5030bb65 (patch)
tree409dbe0d9d71922872937ee461abddf5478d4ed2 /libusb/io.c
parent7c525480ab3c4db9205bfe30bb0d2bef9096c444 (diff)
downloadlibusb-4cd249388e4ed2ca03f1263984ab67df5030bb65.tar.gz
Take lock before raising event waiters condition
This avoids a race between the user checking for active event handler and then blocking on the condition variable
Diffstat (limited to 'libusb/io.c')
-rw-r--r--libusb/io.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/libusb/io.c b/libusb/io.c
index 6a04a2e..6ed19c1 100644
--- a/libusb/io.c
+++ b/libusb/io.c
@@ -1045,7 +1045,9 @@ void usbi_handle_transfer_completion(struct usbi_transfer *itransfer,
* this point. */
if (flags & LIBUSB_TRANSFER_FREE_TRANSFER)
libusb_free_transfer(transfer);
+ pthread_mutex_lock(&event_waiters_lock);
pthread_cond_broadcast(&event_waiters_cond);
+ pthread_mutex_unlock(&event_waiters_lock);
}
/* Similar to usbi_handle_transfer_completion() but exclusively for transfers