aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Markgraf <steve@steve-m.de>2014-01-03 05:54:54 +0100
committerSteve Markgraf <steve@steve-m.de>2014-01-03 05:56:43 +0100
commitd683b128f918778f666349fa511fb9be54b78598 (patch)
treee91be4ef744ff3d5f60783cdf2d9bb13bf0c6cf8
parent3ab6fffbdda5dc2db6e7da2eda996f254210e553 (diff)
lib: abort if submitting transfer fails, don't deadlock when cancelling fails
Signed-off-by: Steve Markgraf <steve@steve-m.de>
-rw-r--r--src/librtlsdr.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/librtlsdr.c b/src/librtlsdr.c
index 13267ef..ad60779 100644
--- a/src/librtlsdr.c
+++ b/src/librtlsdr.c
@@ -1760,7 +1760,12 @@ int rtlsdr_read_async(rtlsdr_dev_t *dev, rtlsdr_read_async_cb_t cb, void *ctx,
(void *)dev,
BULK_TIMEOUT);
- libusb_submit_transfer(dev->xfer[i]);
+ r = libusb_submit_transfer(dev->xfer[i]);
+ if (r < 0) {
+ fprintf(stderr, "Failed to submit transfer %i!\n", i);
+ dev->async_status = RTLSDR_CANCELING;
+ break;
+ }
}
while (RTLSDR_INACTIVE != dev->async_status) {
@@ -1784,7 +1789,10 @@ int rtlsdr_read_async(rtlsdr_dev_t *dev, rtlsdr_read_async_cb_t cb, void *ctx,
if (LIBUSB_TRANSFER_CANCELLED !=
dev->xfer[i]->status) {
- libusb_cancel_transfer(dev->xfer[i]);
+ r = libusb_cancel_transfer(dev->xfer[i]);
+ if (r < 0)
+ continue;
+
next_status = RTLSDR_CANCELING;
}
}