Prior to this commit, the handle_timeout() function would always
set the USBI_TRANSFER_TIMED_OUT flag on the transfer. However, in
some cases the actual cancellation of the transfer does not succeed,
perhaps because the transfer had just completed. This would cause
occasional false reporting of LIBUSB_TRANSFER_TIMED_OUT when the
transfer did not in fact timeout. This commit adds a check for
successful cancellation before setting the transfer flag.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer);
int r;
- itransfer->flags |= USBI_TRANSFER_TIMED_OUT;
r = libusb_cancel_transfer(transfer);
- if (r < 0)
+ if (r == 0)
+ itransfer->flags |= USBI_TRANSFER_TIMED_OUT;
+ else
usbi_warn(TRANSFER_CTX(transfer),
"async cancel failed %d errno=%d", r, errno);
}
-#define LIBUSB_NANO 10995
+#define LIBUSB_NANO 10996