Commit a7580f1ff24b119f5795d2a307254c40ab721aa9

Con Kolivas 2013-10-14T09:40:23

Do not use locking on usb callback function pthread signalling to prevent deadlock with libusb's own event lock.

diff --git a/usbutils.c b/usbutils.c
index 2ab34d4..436475b 100644
--- a/usbutils.c
+++ b/usbutils.c
@@ -2213,9 +2213,7 @@ static void LIBUSB_CALL transfer_callback(struct libusb_transfer *transfer)
 {
 	struct usb_transfer *ut = transfer->user_data;
 
-	mutex_lock(&ut->mutex);
 	pthread_cond_signal(&ut->cond);
-	mutex_unlock(&ut->mutex);
 }
 
 /* Wait for callback function to tell us it has finished the USB transfer, but
@@ -2237,7 +2235,6 @@ static int callback_wait(struct usb_transfer *ut, int *transferred, unsigned int
 		libusb_cancel_transfer(transfer);
 
 		/* Now wait for the callback function to be invoked. */
-		mutex_lock(&ut->mutex);
 		pthread_cond_wait(&ut->cond, &ut->mutex);
 	}
 	ret = transfer->status;