From 5b9cf0f0779a9838e6ec1edc4ac5ff8d72007e51 Mon Sep 17 00:00:00 2001 From: ckolivas Date: Wed, 29 May 2013 12:06:06 +1000 Subject: [PATCH] Send the shutdown message to threads and do the thread shutdown functions before more forcefully sending pthread_cancel to threads. --- cgminer.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) 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;