diff --git a/cgminer.c b/cgminer.c index 85066f78..6950b61a 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;