usbinfo.devlock is only ever write locked so convert it to a mutex
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
diff --git a/usbutils.c b/usbutils.c
index e333b59..35c8865 100644
--- a/usbutils.c
+++ b/usbutils.c
@@ -34,11 +34,11 @@
*/
#define DEVLOCK(cgpu, _pth_state) do { \
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &_pth_state); \
- wr_lock(cgpu->usbinfo.devlock); \
+ mutex_lock(cgpu->usbinfo.devlock); \
} while (0)
#define DEVUNLOCK(cgpu, _pth_state) do { \
- wr_unlock(cgpu->usbinfo.devlock); \
+ mutex_unlock(cgpu->usbinfo.devlock); \
pthread_setcancelstate(_pth_state, NULL); \
} while (0)
@@ -1384,7 +1384,7 @@ struct cgpu_info *usb_alloc_cgpu(struct device_drv *drv, int threads)
if (unlikely(!cgpu->usbinfo.devlock))
quit(1, "Failed to calloc devlock for %s in usb_alloc_cgpu", drv->dname);
- rwlock_init(cgpu->usbinfo.devlock);
+ mutex_init(cgpu->usbinfo.devlock);
return cgpu;
}
@@ -3083,9 +3083,9 @@ void usb_cleanup()
case DRIVER_modminer:
case DRIVER_icarus:
case DRIVER_avalon:
- wr_lock(cgpu->usbinfo.devlock);
+ mutex_lock(cgpu->usbinfo.devlock);
release_cgpu(cgpu);
- wr_unlock(cgpu->usbinfo.devlock);
+ mutex_unlock(cgpu->usbinfo.devlock);
count++;
break;
default:
diff --git a/usbutils.h b/usbutils.h
index f086441..8274c76 100644
--- a/usbutils.h
+++ b/usbutils.h
@@ -237,7 +237,7 @@ struct cg_usb_info {
* that uses the lock - however, all usbutils code MUST use it
* to avoid devices disappearing while in use by multiple threads
*/
- pthread_rwlock_t *devlock;
+ pthread_mutex_t *devlock;
time_t last_pipe;
uint64_t pipe_count;