diff options
author | Vitali Lovich <vlovich@aliph.com> | 2011-09-14 07:02:06 +0200 |
---|---|---|
committer | Peter Stuge <peter@stuge.se> | 2011-10-17 16:25:50 +0200 |
commit | 0c5bf03eb829e51dcf19562fc4f745937235ea51 (patch) | |
tree | 8e1e1044972a0bff0b626b37d8603b2373db5a19 /libusb/os | |
parent | 3e6e257f55156c4600f3116a0befba8cee62872a (diff) | |
download | libusb-0c5bf03eb829e51dcf19562fc4f745937235ea51.tar.gz |
Darwin: Reduce race likelihood between cancellation and device disconnect
References #88. The race condition still remains, but this change
makes it less likely to trigger.
Diffstat (limited to 'libusb/os')
-rw-r--r-- | libusb/os/darwin_usb.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/libusb/os/darwin_usb.c b/libusb/os/darwin_usb.c index 9ebb150..1f356ee 100644 --- a/libusb/os/darwin_usb.c +++ b/libusb/os/darwin_usb.c @@ -1449,6 +1449,9 @@ static int cancel_control_transfer(struct usbi_transfer *itransfer) { usbi_info (ITRANSFER_CTX (itransfer), "WARNING: aborting all transactions control pipe"); + if (!dpriv->device) + return LIBUSB_ERROR_NO_DEVICE; + kresult = (*(dpriv->device))->USBDeviceAbortPipeZero (dpriv->device); return darwin_to_libusb (kresult); @@ -1456,6 +1459,7 @@ static int cancel_control_transfer(struct usbi_transfer *itransfer) { static int darwin_abort_transfers (struct usbi_transfer *itransfer) { struct libusb_transfer *transfer = USBI_TRANSFER_TO_LIBUSB_TRANSFER(itransfer); + struct darwin_device_priv *dpriv = (struct darwin_device_priv *)transfer->dev_handle->dev->os_priv; struct darwin_device_handle_priv *priv = (struct darwin_device_handle_priv *)transfer->dev_handle->os_priv; struct darwin_interface *cInterface; uint8_t pipeRef, iface; @@ -1469,6 +1473,9 @@ static int darwin_abort_transfers (struct usbi_transfer *itransfer) { cInterface = &priv->interfaces[iface]; + if (!dpriv->device) + return LIBUSB_ERROR_NO_DEVICE; + usbi_info (ITRANSFER_CTX (itransfer), "WARNING: aborting all transactions on interface %d pipe %d", iface, pipeRef); /* abort transactions */ |