mirror of
https://github.com/RPCS3/libusb.git
synced 2026-07-21 08:36:02 -04:00
Don't print an error when libusb_cancel_transfer() fails with NOT_FOUND
As stated in the documentation for libusb_cancel_transfer(), LIBUSB_ERROR_NOT_FOUND is an expected return value for libusb_cancel_transfer() under certain circumstances, so printing an error every time this happens is undesirable. Even more so because under Linux IOCTL_USBFS_DISCARDURB sets errno to EINVAL when the kernel can't not find the urb in the kernel's urbs-in-flight list, which means that the urb has already completed at the host controller level but it has not necessarily been reaped yet. IOW under Linux libusb_cancel_transfer() may yield a result of LIBUSB_ERROR_NOT_FOUND *before* the transfer's callback has been called! In conclusion there is no way for applications to avoid calling libusb_cancel_transfer() on already completed transfers, and these errors can and do happen frequently for some USB traffic. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
This commit is contained in:
committed by
Peter Stuge
parent
4db8275da5
commit
98bc7b8d12
+5
-2
@@ -1353,8 +1353,11 @@ int API_EXPORTED libusb_cancel_transfer(struct libusb_transfer *transfer)
|
||||
usbi_mutex_lock(&itransfer->lock);
|
||||
r = usbi_backend->cancel_transfer(itransfer);
|
||||
if (r < 0) {
|
||||
usbi_err(TRANSFER_CTX(transfer),
|
||||
"cancel transfer failed error %d", r);
|
||||
if (r != LIBUSB_ERROR_NOT_FOUND)
|
||||
usbi_err(TRANSFER_CTX(transfer),
|
||||
"cancel transfer failed error %d", r);
|
||||
else
|
||||
usbi_dbg("cancel transfer failed error %d", r);
|
||||
|
||||
if (r == LIBUSB_ERROR_NO_DEVICE)
|
||||
itransfer->flags |= USBI_TRANSFER_DEVICE_DISAPPEARED;
|
||||
|
||||
Reference in New Issue
Block a user