klondike - single 'shutdown' and ensure it happens
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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
diff --git a/driver-klondike.c b/driver-klondike.c
index 0d6d157..35d2a9a 100644
--- a/driver-klondike.c
+++ b/driver-klondike.c
@@ -199,7 +199,6 @@ typedef struct jobque {
} JOBQUE;
struct klondike_info {
- bool shutdown;
pthread_rwlock_t stat_lock;
struct thr_info replies_thr;
cglock_t klist_lock;
@@ -540,7 +539,7 @@ static KLIST *GetReply(struct cgpu_info *klncgpu, uint8_t cmd, uint8_t dev)
KLIST *kitem;
int retries = CMD_REPLY_RETRIES;
- while (retries-- > 0 && klninfo->shutdown == false) {
+ while (retries-- > 0 && klncgpu->shutdown == false) {
cgsleep_ms(REPLY_WAIT_TIME);
cg_rlock(&klninfo->klist_lock);
kitem = klninfo->used;
@@ -953,7 +952,7 @@ static void *klondike_get_replies(void *userdata)
applog(LOG_DEBUG, "%s%i: listening for replies",
klncgpu->drv->name, klncgpu->device_id);
- while (klninfo->shutdown == false) {
+ while (klncgpu->shutdown == false) {
if (klncgpu->usbinfo.nodev)
return NULL;
@@ -1028,7 +1027,7 @@ static void *klondike_get_replies(void *userdata)
dev, (char)(kitem->kline.ws.cmd),
(int)(kitem->kline.ws.slavecount),
slaves);
- klninfo->shutdown = true;
+ klncgpu->shutdown = true;
break;
}
@@ -1054,7 +1053,7 @@ static void *klondike_get_replies(void *userdata)
klncgpu->drv->name,
klncgpu->device_id,
dev);
- klninfo->shutdown = true;
+ klncgpu->shutdown = true;
}
kln_disable(klncgpu, dev, false);
}
@@ -1157,7 +1156,7 @@ static void klondike_shutdown(struct thr_info *thr)
kln_disable(klncgpu, klninfo->status[0].kline.ws.slavecount, true);
- klncgpu->shutdown = klninfo->shutdown = true;
+ klncgpu->shutdown = true;
}
static void klondike_thread_enable(struct thr_info *thr)
@@ -1272,7 +1271,7 @@ static bool klondike_queue_full(struct cgpu_info *klncgpu)
rd_unlock(&(klninfo->stat_lock));
applog(LOG_ERR, "%s%i:%d reset failed - dropping device",
klncgpu->drv->name, klncgpu->device_id, dev);
- klninfo->shutdown = true;
+ klncgpu->shutdown = true;
return false;
}
break;
@@ -1360,7 +1359,11 @@ static int64_t klondike_scanwork(struct thr_info *thr)
klninfo->noncecount = 0;
rd_unlock(&(klninfo->stat_lock));
}
- return newhashcount;
+
+ if (klncgpu->shutdown)
+ return -1;
+ else
+ return newhashcount;
}