mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-25 14:04:25 +00:00
Revert to using timeouts on !linux since libusb leaks memory without them.
This commit is contained in:
parent
74a4ccba28
commit
103bc0bafe
14
usbutils.c
14
usbutils.c
@ -2242,7 +2242,7 @@ static int callback_wait(struct usb_transfer *ut, int *transferred, unsigned int
|
|||||||
cgsem_wait(&ut->cgsem);
|
cgsem_wait(&ut->cgsem);
|
||||||
}
|
}
|
||||||
ret = transfer->status;
|
ret = transfer->status;
|
||||||
if (ret == LIBUSB_TRANSFER_CANCELLED)
|
if (ret == LIBUSB_TRANSFER_CANCELLED || ret == LIBUSB_TRANSFER_TIMED_OUT)
|
||||||
ret = LIBUSB_ERROR_TIMEOUT;
|
ret = LIBUSB_ERROR_TIMEOUT;
|
||||||
|
|
||||||
/* No need to sort out mutexes here since they won't be reused */
|
/* No need to sort out mutexes here since they won't be reused */
|
||||||
@ -2290,10 +2290,15 @@ usb_bulk_transfer(struct libusb_device_handle *dev_handle, int intinfo,
|
|||||||
USBDEBUG("USB debug: @usb_bulk_transfer(%s (nodev=%s),intinfo=%d,epinfo=%d,data=%p,length=%d,timeout=%u,mode=%d,cmd=%s,seq=%d) endpoint=%d", cgpu->drv->name, bool_str(cgpu->usbinfo.nodev), intinfo, epinfo, data, length, timeout, mode, usb_cmdname(cmd), seq, (int)endpoint);
|
USBDEBUG("USB debug: @usb_bulk_transfer(%s (nodev=%s),intinfo=%d,epinfo=%d,data=%p,length=%d,timeout=%u,mode=%d,cmd=%s,seq=%d) endpoint=%d", cgpu->drv->name, bool_str(cgpu->usbinfo.nodev), intinfo, epinfo, data, length, timeout, mode, usb_cmdname(cmd), seq, (int)endpoint);
|
||||||
|
|
||||||
init_usb_transfer(&ut);
|
init_usb_transfer(&ut);
|
||||||
|
#ifdef LINUX
|
||||||
/* We give the transfer no timeout since we manage timeouts ourself */
|
/* We give the transfer no timeout since we manage timeouts ourself */
|
||||||
libusb_fill_bulk_transfer(ut.transfer, dev_handle, endpoint, buf, length,
|
libusb_fill_bulk_transfer(ut.transfer, dev_handle, endpoint, buf, length,
|
||||||
transfer_callback, &ut, 0);
|
transfer_callback, &ut, 0);
|
||||||
|
#else
|
||||||
|
/* All other OSes not so lucky */
|
||||||
|
libusb_fill_bulk_transfer(ut.transfer, dev_handle, endpoint, buf, length,
|
||||||
|
transfer_callback, &ut, timeout);
|
||||||
|
#endif
|
||||||
STATS_TIMEVAL(&tv_start);
|
STATS_TIMEVAL(&tv_start);
|
||||||
cg_rlock(&cgusb_fd_lock);
|
cg_rlock(&cgusb_fd_lock);
|
||||||
err = libusb_submit_transfer(ut.transfer);
|
err = libusb_submit_transfer(ut.transfer);
|
||||||
@ -2729,8 +2734,13 @@ static int usb_control_transfer(struct cgpu_info *cgpu, libusb_device_handle *de
|
|||||||
wIndex, wLength);
|
wIndex, wLength);
|
||||||
if ((bmRequestType & LIBUSB_ENDPOINT_DIR_MASK) == LIBUSB_ENDPOINT_OUT)
|
if ((bmRequestType & LIBUSB_ENDPOINT_DIR_MASK) == LIBUSB_ENDPOINT_OUT)
|
||||||
memcpy(buf + LIBUSB_CONTROL_SETUP_SIZE, buffer, wLength);
|
memcpy(buf + LIBUSB_CONTROL_SETUP_SIZE, buffer, wLength);
|
||||||
|
#ifdef LINUX
|
||||||
libusb_fill_control_transfer(ut.transfer, dev_handle, buf, transfer_callback,
|
libusb_fill_control_transfer(ut.transfer, dev_handle, buf, transfer_callback,
|
||||||
&ut, 0);
|
&ut, 0);
|
||||||
|
#else
|
||||||
|
libusb_fill_control_transfer(ut.transfer, dev_handle, buf, transfer_callback,
|
||||||
|
&ut, timeout);
|
||||||
|
#endif
|
||||||
err = libusb_submit_transfer(ut.transfer);
|
err = libusb_submit_transfer(ut.transfer);
|
||||||
if (!err)
|
if (!err)
|
||||||
err = callback_wait(&ut, &transferred, timeout);
|
err = callback_wait(&ut, &transferred, timeout);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user