Commit 382433eb73a243678b174232c917c178dcc06ad9

Con Kolivas 2013-10-01T17:34:32

Fake the libusb transfer timed out message if we force cancel it with our own async functions.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
diff --git a/usbutils.c b/usbutils.c
index 67a611f..119592c 100644
--- a/usbutils.c
+++ b/usbutils.c
@@ -2242,9 +2242,11 @@ static int callback_wait(struct usb_transfer *ut, int *transferred, unsigned int
 	if (ret) {
 		libusb_cancel_transfer(ut->transfer);
 		pthread_cond_wait(&ut->cond, &ut->mutex);
-	}
+		/* Fake the timed out message since it's effectively that */
+		ret = LIBUSB_TRANSFER_TIMED_OUT;
+	} else
+		ret = ut->transfer->status;
 	/* No need to sort out mutexes here since they won't be reused */
-	ret = ut->transfer->status;
 	*transferred = ut->transfer->actual_length;
 	libusb_free_transfer(ut->transfer);