Skip to content

Commit

Permalink
[EMUG29PS4] Possible deadlock when closing gimx #348
Browse files Browse the repository at this point in the history
  • Loading branch information
Matlo committed Oct 13, 2015
1 parent 77eeede commit 57ef465
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion shared/async/src/linux/usbhidasync.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ static struct {
ASYNC_CLOSE_CALLBACK fp_close;
} callback;
int pending_transfers;
int closing;
} usbdevices[USBHIDASYNC_MAX_DEVICES] = { };

#if !defined(LIBUSB_API_VERSION) && !defined(LIBUSBX_API_VERSION)
Expand Down Expand Up @@ -243,7 +244,7 @@ static void usb_callback(struct libusb_transfer* transfer) {
}

if (transfer->endpoint == usbdevices[device].config.endpoints.in.address
&& transfer->status != LIBUSB_TRANSFER_CANCELLED) {
&& transfer->status != LIBUSB_TRANSFER_CANCELLED && !usbdevices[device].closing) {

submit_transfer(transfer);
} else {
Expand Down Expand Up @@ -846,6 +847,8 @@ int usbhidasync_close(int device) {

USBHIDASYNC_CHECK_DEVICE(device, -1)

usbdevices[device].closing = 1;

cancel_transfers(device);

libusb_release_interface(usbdevices[device].devh, usbdevices[device].config.interface.number); //warning: this is a blocking function
Expand Down

0 comments on commit 57ef465

Please sign in to comment.