Permalink
Browse files

Linux/libusb: Shutdown thread if it's not possible to submit transfer

This happens if a device gets opened a second time. The call to
libusb_submit_transfer() will fail, indicating that the read thread should
be shut down.
  • Loading branch information...
1 parent 992fef2 commit 1bde0321709c8a15d5623f599dc43eed3aa2dde1 @signal11 committed Apr 23, 2012
Showing with 6 additions and 1 deletion.
  1. +6 −1 linux/hid-libusb.c
View
@@ -622,6 +622,7 @@ hid_device * hid_open(unsigned short vendor_id, unsigned short product_id, const
static void read_callback(struct libusb_transfer *transfer)
{
hid_device *dev = transfer->user_data;
+ int res;
if (transfer->status == LIBUSB_TRANSFER_COMPLETED) {
@@ -674,7 +675,11 @@ static void read_callback(struct libusb_transfer *transfer)
}
/* Re-submit the transfer object. */
- libusb_submit_transfer(transfer);
+ res = libusb_submit_transfer(transfer);
+ if (res != 0) {
+ LOG("Unable to submit URB. libusb error code: %d\n", res);
+ dev->shutdown_thread = 1;
+ }
}

0 comments on commit 1bde032

Please sign in to comment.