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.
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;
}
/* Set by backend submit_transfer() if the OS handles timeout */
USBI_TRANSFER_OS_HANDLES_TIMEOUT = 1 << 1,
+
+ /* Cancellation was requested via libusb_cancel_transfer() */
+ USBI_TRANSFER_CANCELLING = 1 << 2,
+
+ /* Operation on the transfer failed because the device disappeared */
+ USBI_TRANSFER_DEVICE_DISAPPEARED = 1 << 3,
};
#define __USBI_TRANSFER_TO_LIBUSB_TRANSFER(transfer) \