Browse Source

Cancel cancellable usb transfers on work restart messages.

nfactor-troky
Con Kolivas 11 years ago
parent
commit
d2feacdfb2
  1. 4
      cgminer.c
  2. 16
      usbutils.c
  3. 4
      usbutils.h

4
cgminer.c

@ -3929,6 +3929,10 @@ static void restart_threads(void) @@ -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

@ -2217,6 +2217,22 @@ struct usb_transfer { @@ -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);

4
usbutils.h

@ -356,6 +356,7 @@ enum usb_cmds { @@ -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); @@ -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…
Cancel
Save