Browse Source

Destroy cgsems used after transfers to not leave open files on osx.

nfactor-troky
Con Kolivas 11 years ago
parent
commit
ad8d94979f
  1. 10
      usbutils.c

10
usbutils.c

@ -2219,6 +2219,12 @@ static void init_usb_transfer(struct usb_transfer *ut)
ut->transfer->user_data = ut; ut->transfer->user_data = ut;
} }
static void complete_usb_transfer(struct usb_transfer *ut)
{
cgsem_destroy(&ut->cgsem);
libusb_free_transfer(ut->transfer);
}
static void LIBUSB_CALL transfer_callback(struct libusb_transfer *transfer) static void LIBUSB_CALL transfer_callback(struct libusb_transfer *transfer)
{ {
struct usb_transfer *ut = transfer->user_data; struct usb_transfer *ut = transfer->user_data;
@ -2306,7 +2312,7 @@ usb_bulk_transfer(struct libusb_device_handle *dev_handle, int intinfo,
errn = errno; errn = errno;
if (!err) if (!err)
err = callback_wait(&ut, transferred, timeout); err = callback_wait(&ut, transferred, timeout);
libusb_free_transfer(ut.transfer); complete_usb_transfer(&ut);
STATS_TIMEVAL(&tv_finish); STATS_TIMEVAL(&tv_finish);
USB_STATS(cgpu, &tv_start, &tv_finish, err, mode, cmd, seq, timeout); USB_STATS(cgpu, &tv_start, &tv_finish, err, mode, cmd, seq, timeout);
@ -2754,7 +2760,7 @@ static int usb_control_transfer(struct cgpu_info *cgpu, libusb_device_handle *de
if ((err) == LIBUSB_TRANSFER_CANCELLED) if ((err) == LIBUSB_TRANSFER_CANCELLED)
err = LIBUSB_ERROR_TIMEOUT; err = LIBUSB_ERROR_TIMEOUT;
out: out:
libusb_free_transfer(ut.transfer); complete_usb_transfer(&ut);
return err; return err;
} }

Loading…
Cancel
Save