Browse Source

immediately exit threads if doing hard reset

djm34
Jan Berdajs 10 years ago
parent
commit
deacbdd65e
  1. 14
      sgminer.c

14
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))) if (unlikely(pthread_create(&restart_thr, NULL, restart_mining_threads_thread, (void *) (intptr_t) n_threads)))
quit(1, "restart_mining_threads create thread failed"); 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 else
{ {
@ -6521,9 +6522,16 @@ static void get_work_prepare_thread(struct thr_info *mythr, struct work *work)
return; return;
} }
} }
else else {
bool hard_reset = opt_isset(pool_switch_options, SWITCHER_HARD_RESET);
mutex_unlock(&algo_switch_lock); 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); pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
// Set cleanup instructions in the event that the thread is cancelled // 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++) for (i = 0; i < mining_threads; i++)
{ {
applog(LOG_DEBUG, "Shutting down thread %d", 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); rd_unlock(&mining_thr_lock);

Loading…
Cancel
Save