Send the shutdown message to threads and do the thread shutdown functions before more forcefully sending pthread_cancel to threads.
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
diff --git a/cgminer.c b/cgminer.c
index 85066f7..6950b61 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -2809,17 +2809,29 @@ static void __kill_work(void)
thr = &control_thr[watchdog_thr_id];
thr_info_cancel(thr);
- applog(LOG_DEBUG, "Killing off mining threads");
- /* Kill the mining threads*/
+ applog(LOG_DEBUG, "Shutting down mining threads");
for (i = 0; i < mining_threads; i++) {
- pthread_t *pth = NULL;
+ struct cgpu_info *cgpu;
+ struct device_drv *drv;
thr = get_thread(i);
- if (thr) {
- struct device_drv *drv = thr->cgpu->drv;
+ if (!thr)
+ continue;
+ cgpu = thr->cgpu;
+ if (!cgpu)
+ continue;
+ drv = cgpu->drv;
+ if (!drv)
+ continue;
- drv->thread_shutdown(thr);
- }
+ cgpu->shutdown = true;
+ drv->thread_shutdown(thr);
+ }
+
+ applog(LOG_DEBUG, "Killing off mining threads");
+ /* Kill the mining threads*/
+ for (i = 0; i < mining_threads; i++) {
+ pthread_t *pth = NULL;
if (thr && PTH(thr) != 0L)
pth = &thr->pth;