From ecd03cefb7150b7532a321ed0b2889ebc1dd546a Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Sun, 19 May 2013 12:55:20 +1000 Subject: [PATCH] Properly pthread_join miner threads on shutdown. --- cgminer.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cgminer.c b/cgminer.c index 1b04fdd4..f53c754f 100644 --- a/cgminer.c +++ b/cgminer.c @@ -2804,10 +2804,14 @@ static void __kill_work(void) applog(LOG_DEBUG, "Killing off mining threads"); /* Kill the mining threads*/ for (i = 0; i < mining_threads; i++) { + pthread_t *pth = NULL; + thr = get_thread(i); + if (thr && PTH(thr) != 0L) + pth = &thr->pth; thr_info_cancel(thr); - if (thr && thr->pth) - pthread_join(thr->pth, NULL); + if (pth) + pthread_join(*pth, NULL); } applog(LOG_DEBUG, "Killing off stage thread");