aboutsummaryrefslogtreecommitdiffstats
path: root/libusb/io.c
diff options
context:
space:
mode:
authorVitali Lovich <vlovich@aliph.com>2011-03-16 19:48:35 -0700
committerPeter Stuge <peter@stuge.se>2011-07-24 22:29:09 +0200
commit8f1bc0659136faf312dabe8fe67380a798299d33 (patch)
tree23290014a82f762f04a275103f27db0a20d0fe34 /libusb/io.c
parent87ba8a9ead4fd9e81ae3c5a894f698779de1f2c2 (diff)
downloadandroid_external_libusbx-8f1bc0659136faf312dabe8fe67380a798299d33.tar.gz
android_external_libusbx-8f1bc0659136faf312dabe8fe67380a798299d33.tar.bz2
android_external_libusbx-8f1bc0659136faf312dabe8fe67380a798299d33.zip
Add USBI_TRANSFER_CANCELLING and _DEVICE_DISAPPEARED status flags
The flags are used to indicate if a cancellation has started, and if a cancellation has failed because the device is no longer available. References #82.
Diffstat (limited to 'libusb/io.c')
-rw-r--r--libusb/io.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/libusb/io.c b/libusb/io.c
index 56c1d34..3ef422a 100644
--- a/libusb/io.c
+++ b/libusb/io.c
@@ -1309,9 +1309,16 @@ int API_EXPORTED libusb_cancel_transfer(struct libusb_transfer *transfer)
usbi_dbg("");
usbi_mutex_lock(&itransfer->lock);
r = usbi_backend->cancel_transfer(itransfer);
- if (r < 0)
+ if (r < 0) {
usbi_err(TRANSFER_CTX(transfer),
"cancel transfer failed error %d", r);
+
+ if (r == LIBUSB_ERROR_NO_DEVICE)
+ itransfer->flags |= USBI_TRANSFER_DEVICE_DISAPPEARED;
+ }
+
+ itransfer->flags |= USBI_TRANSFER_CANCELLING;
+
usbi_mutex_unlock(&itransfer->lock);
return r;
}