summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Dickens <christopher.a.dickens@gmail.com>2015-08-02 23:26:19 -0700
committerChris Dickens <christopher.a.dickens@gmail.com>2015-08-04 22:53:03 -0700
commitefd02e7348d9ac769235377b3d7395ecf1fdd0d9 (patch)
tree14ef7d4d12a54b355044a9a8ef457d65fb314f1c
parent13a90e43acd40e0993790ac354eb7a5a3745a2b2 (diff)
downloadlibusb-efd02e7348d9ac769235377b3d7395ecf1fdd0d9.tar.gz
core: Correctly report cancellations due to timeouts
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>
-rw-r--r--libusb/io.c5
-rw-r--r--libusb/version_nano.h2
2 files changed, 4 insertions, 3 deletions
diff --git a/libusb/io.c b/libusb/io.c
index 2937ad9..420f87a 100644
--- a/libusb/io.c
+++ b/libusb/io.c
@@ -1944,9 +1944,10 @@ static void handle_timeout(struct usbi_transfer *itransfer)
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);
}
diff --git a/libusb/version_nano.h b/libusb/version_nano.h
index bdb6213..7f6727f 100644
--- a/libusb/version_nano.h
+++ b/libusb/version_nano.h
@@ -1 +1 @@
-#define LIBUSB_NANO 10995
+#define LIBUSB_NANO 10996