diff options
author | Zoltán Kovács <0x4b5a@gmail.com> | 2013-01-29 00:14:29 +0000 |
---|---|---|
committer | Pete Batard <pete@akeo.ie> | 2013-01-29 00:21:58 +0000 |
commit | 2f5023c41d3176e56bf0abc521b7c5f8b1ac4664 (patch) | |
tree | ab7bf22d06e6ada5e4f865611b4409b01f64c689 /libusb/sync.c | |
parent | 1d8e1270ce5256fc894f130d2ea113d6d78d6cbf (diff) | |
download | libusb-2f5023c41d3176e56bf0abc521b7c5f8b1ac4664.tar.gz |
Core: Don't wait for completion if cancel_transfer failed
* See http://libusbx.1081486.n5.nabble.com/Libusbx-devel-libusb-interrupt-transfer-does-not-return-in-case-of-error-td626.html
* Closes #76
Diffstat (limited to 'libusb/sync.c')
-rw-r--r-- | libusb/sync.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/libusb/sync.c b/libusb/sync.c index 5033387..b9a72e4 100644 --- a/libusb/sync.c +++ b/libusb/sync.c @@ -106,10 +106,11 @@ int API_EXPORTED libusb_control_transfer(libusb_device_handle *dev_handle, if (r < 0) { if (r == LIBUSB_ERROR_INTERRUPTED) continue; - libusb_cancel_transfer(transfer); - while (!completed) - if (libusb_handle_events_completed(HANDLE_CTX(dev_handle), &completed) < 0) - break; + if (libusb_cancel_transfer(transfer) == LIBUSB_SUCCESS) { + while (!completed) + if (libusb_handle_events_completed(HANDLE_CTX(dev_handle), &completed) < 0) + break; + } libusb_free_transfer(transfer); return r; } @@ -183,10 +184,11 @@ static int do_sync_bulk_transfer(struct libusb_device_handle *dev_handle, if (r < 0) { if (r == LIBUSB_ERROR_INTERRUPTED) continue; - libusb_cancel_transfer(transfer); - while (!completed) - if (libusb_handle_events_completed(HANDLE_CTX(dev_handle), &completed) < 0) - break; + if (libusb_cancel_transfer(transfer) == LIBUSB_SUCCESS) { + while (!completed) + if (libusb_handle_events_completed(HANDLE_CTX(dev_handle), &completed) < 0) + break; + } libusb_free_transfer(transfer); return r; } |