Possible bug in device removal detection code in librtlsdr.c

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/osmocom-sdr@lists.osmocom.org/.

Alexey Kruglov alexey.kruglov at gmail.com
Tue Jul 16 17:42:54 UTC 2013


Device removal detection code in _libusb_callback in librtlsdr.c may be
buggy. Every time we get any status other than LIBUSB_TRANSFER_COMPLETED
(including LIBUSB_TRANSFER_ERROR) the code doesn't resubmit current
buffer, and we get the real number of working buffers decreased by one.
If that number goes down to 0, rtlsdr_read_async() will hang.

Linux version tries to control it by counting the number of
LIBUSB_TRANSFER_ERROR buffers that came in row in dev->xfer_errors. But
if we already have _one_ failed buffer during the whole transfer up to
the moment, that counter will never reach dev->xfer_buf_num.

So it seems more straightforward to 1. count the failed buffers and
rtlsdr_cancel_async() when it reaches 0 or some sensible threshold, and
2. maybe resubmit some kinds of the failed buffers other than
LIBUSB_TRANSFER_COMPLETED, if it makes sense. I am not a libusb guru and
it's not well documented in this part, so I am not sure about my second

Hoping some librtlsdr developers will appear on this list.

GPG fp: 6DFA 1186 7576 DE60 6CCB  EB39 AD81 1733 EEBB 970A

More information about the osmocom-sdr mailing list