mirror of
https://github.com/GOSTSec/sgminer
synced 2025-02-02 01:44:23 +00:00
Cancel cancellable usb transfers on work restart messages.
This commit is contained in:
parent
51660838da
commit
d2feacdfb2
@ -3929,6 +3929,10 @@ static void restart_threads(void)
|
||||
mutex_lock(&restart_lock);
|
||||
pthread_cond_broadcast(&restart_cond);
|
||||
mutex_unlock(&restart_lock);
|
||||
|
||||
#ifdef USE_USBUTILS
|
||||
cancel_usb_transfers();
|
||||
#endif
|
||||
}
|
||||
|
||||
static void set_curblock(char *hexstr, unsigned char *hash)
|
||||
|
16
usbutils.c
16
usbutils.c
@ -2217,6 +2217,22 @@ struct usb_transfer {
|
||||
struct list_head list;
|
||||
};
|
||||
|
||||
void cancel_usb_transfers(void)
|
||||
{
|
||||
struct usb_transfer *ut;
|
||||
int cancellations = 0;
|
||||
|
||||
cg_rlock(&cgusb_fd_lock);
|
||||
list_for_each_entry(ut, &ct_list, list) {
|
||||
libusb_cancel_transfer(ut->transfer);
|
||||
cancellations++;
|
||||
}
|
||||
cg_runlock(&cgusb_fd_lock);
|
||||
|
||||
if (cancellations)
|
||||
applog(LOG_DEBUG, "Cancelled %d USB transfers", cancellations);
|
||||
}
|
||||
|
||||
static void init_usb_transfer(struct usb_transfer *ut)
|
||||
{
|
||||
cgsem_init(&ut->cgsem);
|
||||
|
@ -356,6 +356,7 @@ enum usb_cmds {
|
||||
struct device_drv;
|
||||
struct cgpu_info;
|
||||
|
||||
void cancel_usb_transfers(void);
|
||||
void usb_all(int level);
|
||||
const char *usb_cmdname(enum usb_cmds cmd);
|
||||
void usb_applog(struct cgpu_info *bflsc, enum usb_cmds cmd, char *msg, int amount, int err);
|
||||
@ -409,6 +410,9 @@ void *usb_resource_thread(void *userdata);
|
||||
#define usb_read_once_timeout(cgpu, buf, bufsiz, read, timeout, cmd) \
|
||||
_usb_read(cgpu, DEFAULT_INTINFO, DEFAULT_EP_IN, buf, bufsiz, read, timeout, NULL, cmd, true, false)
|
||||
|
||||
#define usb_read_once_timeout_cancellable(cgpu, buf, bufsiz, read, timeout, cmd) \
|
||||
_usb_read(cgpu, DEFAULT_INTINFO, DEFAULT_EP_IN, buf, bufsiz, read, timeout, NULL, cmd, true, true)
|
||||
|
||||
#define usb_read_ii_once_timeout(cgpu, intinfo, buf, bufsiz, read, timeout, cmd) \
|
||||
_usb_read(cgpu, intinfo, DEFAULT_EP_IN, buf, bufsiz, read, timeout, NULL, cmd, true, false)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user