Linux: Fix cancel_transfer return value when cancelling a multi-urb transfer
authorHans de Goede <hdegoede@redhat.com>
Mon, 26 Mar 2012 20:33:39 +0000 (21:33 +0100)
committerPete Batard <pete@akeo.ie>
Mon, 26 Mar 2012 20:41:40 +0000 (21:41 +0100)
* if we've successfully cancelled the last urb, and then another urb
  fails with errno == EINVAL, we shouldn't return LIBUSB_ERROR_NOT_FOUND

libusb/os/linux_usbfs.c

index ad3c37a..703d844 100644 (file)
@@ -1483,7 +1483,8 @@ static int discard_urbs(struct usbi_transfer *itransfer, int first, int last_plu
 
                if (EINVAL == errno) {
                        usbi_dbg("URB not found --> assuming ready to be reaped");
-                       ret = LIBUSB_ERROR_NOT_FOUND;
+                       if (i == (last_plus_one - 1))
+                               ret = LIBUSB_ERROR_NOT_FOUND;
                } else if (ENODEV == errno) {
                        usbi_dbg("Device not found for URB --> assuming ready to be reaped");
                        ret = LIBUSB_ERROR_NO_DEVICE;