Linux: Detect and report that device has gone away while discarding URBs
authorVitali Lovich <vlovich@aliph.com>
Thu, 17 Mar 2011 02:50:04 +0000 (19:50 -0700)
committerPeter Stuge <peter@stuge.se>
Sun, 24 Jul 2011 20:29:09 +0000 (22:29 +0200)
Return LIBUSB_ERROR_NO_DEVICE if the device is no longer available
(ENODEV) to discard the urbs. References #82.

libusb/os/linux_usbfs.c

index 6760508..277634a 100644 (file)
@@ -1401,6 +1401,9 @@ 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;
+               } else if (ENODEV == errno) {
+                       usbi_dbg("Device not found for URB --> assuming ready to be reaped");
+                       ret = LIBUSB_ERROR_NO_DEVICE;
                } else {
                        usbi_warn(TRANSFER_CTX(transfer),
                                "unrecognised discard errno %d", errno);