From deacbdd65e9e988b4f8a6fd54688c69eda8886d0 Mon Sep 17 00:00:00 2001 From: Jan Berdajs Date: Mon, 7 Jul 2014 03:05:22 +0200 Subject: [PATCH] immediately exit threads if doing hard reset --- sgminer.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/sgminer.c b/sgminer.c index 2d4577dd..fc36c36a 100644 --- a/sgminer.c +++ b/sgminer.c @@ -6505,7 +6505,8 @@ static void get_work_prepare_thread(struct thr_info *mythr, struct work *work) if (unlikely(pthread_create(&restart_thr, NULL, restart_mining_threads_thread, (void *) (intptr_t) n_threads))) quit(1, "restart_mining_threads create thread failed"); - // go wait with the other threads... + applog(LOG_DEBUG, "Hard reset: Exiting mining thread %d", mythr->id); + pthread_exit(NULL); } else { @@ -6521,9 +6522,16 @@ static void get_work_prepare_thread(struct thr_info *mythr, struct work *work) return; } } - else + else { + bool hard_reset = opt_isset(pool_switch_options, SWITCHER_HARD_RESET); mutex_unlock(&algo_switch_lock); + if (hard_reset) { + applog(LOG_DEBUG, "Hard reset: Exiting mining thread %d", mythr->id); + pthread_exit(NULL); + } + } + pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); // Set cleanup instructions in the event that the thread is cancelled @@ -8009,7 +8017,7 @@ static void restart_mining_threads(unsigned int new_n_threads) for (i = 0; i < mining_threads; i++) { applog(LOG_DEBUG, "Shutting down thread %d", i); - mining_thr[i]->cgpu->shutdown = true; + mining_thr[i]->cgpu->shutdown = true; } rd_unlock(&mining_thr_lock);