From e33590f37d060cebd7ef5d7c1f929926fbe21e29 Mon Sep 17 00:00:00 2001 From: Jan Berdajs Date: Mon, 7 Jul 2014 04:20:41 +0200 Subject: [PATCH] Thread was never joined because thr_info_cancel sets pth to 0. Should improve mining thread hard reset. --- sgminer.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sgminer.c b/sgminer.c index 1c670b7d..15008c37 100644 --- a/sgminer.c +++ b/sgminer.c @@ -3322,11 +3322,11 @@ static void kill_mining(void) /* Kill the mining threads*/ rd_lock(&mining_thr_lock); for (i = 0; i < mining_threads; i++) { - pthread_t *pth = NULL; + pthread_t *pth = (pthread_t *) calloc(1, sizeof(pthread_t)); thr = mining_thr[i]; if (thr && PTH(thr) != 0L) - pth = &thr->pth; + *pth = thr->pth; thr_info_cancel(thr); forcelog(LOG_DEBUG, "Waiting for thread %d to finish...", thr->id); #ifndef WIN32 @@ -3336,6 +3336,7 @@ static void kill_mining(void) if (pth && pth->p) pthread_join(*pth, NULL); #endif + free(pth); } rd_unlock(&mining_thr_lock); }