diff options
| author | 2026-10-06 16:11:22 +0200 | |
|---|---|---|
| committer | 2026-11-22 18:14:11 +0100 | |
| commit | 8237581c5594e631d7a390f935790d96b7b59b2e (patch) | |
| tree | 0290b010e636688270d165c5b18528899023bb30 /src/usb.c | |
| parent | b474a7925468cb10cc3894d10f2c09a77d31d11f (diff) | |
| download | usbmuxd-8237581c5594e631d7a390f935790d96b7b59b2e.tar.gz usbmuxd-8237581c5594e631d7a390f935790d96b7b59b2e.tar.bz2 | |
usb: clean up RX transfers when resubmission fails
A failed resubmission leaves an inactive transfer in rx_xfers. Cancelling
it cannot produce a callback, so usb_disconnect waits indefinitely.
Route resubmission failures through the existing cleanup path.
Assisted-by: OpenAI Codex
Diffstat (limited to 'src/usb.c')
| -rw-r--r-- | src/usb.c | 19 |
1 files changed, 11 insertions, 8 deletions
@@ -226,7 +226,10 @@ static void rx_callback(struct libusb_transfer *xfer) usbmuxd_log(LL_SPEW, "RX callback dev %d-%d len %d status %d", dev->bus, dev->address, xfer->actual_length, xfer->status); if(xfer->status == LIBUSB_TRANSFER_COMPLETED) { device_data_input(dev, xfer->buffer, xfer->actual_length); - libusb_submit_transfer(xfer); + int res = libusb_submit_transfer(xfer); + if (res == 0) + return; + usbmuxd_log(LL_ERROR, "Failed to resubmit RX transfer to device %d-%d: %s", dev->bus, dev->address, libusb_error_name(res)); } else { switch(xfer->status) { case LIBUSB_TRANSFER_COMPLETED: //shut up compiler @@ -255,15 +258,15 @@ static void rx_callback(struct libusb_transfer *xfer) // this should never be reached. break; } + } - free(xfer->buffer); - collection_remove(&dev->rx_xfers, xfer); - libusb_free_transfer(xfer); + free(xfer->buffer); + collection_remove(&dev->rx_xfers, xfer); + libusb_free_transfer(xfer); - // we can't usb_disconnect here due to a deadlock, so instead mark it as dead and reap it after processing events - // we'll do device_remove there too - dev->alive = 0; - } + // we can't usb_disconnect here due to a deadlock, so instead mark it as dead and reap it after processing events + // we'll do device_remove there too + dev->alive = 0; } // Start a read-callback loop for this device |
