From e53b9d5717b63a8df79c671a58f69b71cf39affa Mon Sep 17 00:00:00 2001 From: Martin Ling Date: Tue, 20 Sep 2022 02:07:21 +0100 Subject: [PATCH] Fix hang in TX when a libusb error occurs. Where our callback is called with a status other than COMPLETED, something abnormal has happened and we no longer want to either submit further transfers or await a flush. So clear the streaming and flush flags, and proceed to transfer_finished. Do the same in the case where libusb_submit_transfer fails when called to submit the flush transfer. --- host/libhackrf/src/hackrf.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/host/libhackrf/src/hackrf.c b/host/libhackrf/src/hackrf.c index 1a14ee75..1be670ae 100644 --- a/host/libhackrf/src/hackrf.c +++ b/host/libhackrf/src/hackrf.c @@ -1830,8 +1830,15 @@ hackrf_libusb_transfer_callback(struct libusb_transfer* usb_transfer) if (resubmit && result == LIBUSB_SUCCESS) return; } else if (device->flush) { - libusb_submit_transfer(device->flush_transfer); + result = libusb_submit_transfer(device->flush_transfer); + if (result != LIBUSB_SUCCESS) { + device->streaming = false; + device->flush = false; + } } + } else { + device->streaming = false; + device->flush = false; } // Unless we resubmitted this transfer and returned above,