1
0
mirror of https://github.com/GOSTSec/sgminer synced 2025-01-10 23:08:07 +00:00

fix segfault (watchdog thread declares threads sick and tries to restart them while they are already being restarted)

This commit is contained in:
Jan Berdajs 2014-06-05 22:55:11 +02:00
parent a5bec2b999
commit 00d17d16fe

View File

@ -7412,6 +7412,8 @@ static void *watchdog_thread(void __maybe_unused *userdata)
hashmeter(-1, &zero_tv, 0);
rd_lock(&mining_thr_lock);
#ifdef HAVE_CURSES
if (curses_active_locked()) {
struct cgpu_info *cgpu;
@ -7547,6 +7549,7 @@ static void *watchdog_thread(void __maybe_unused *userdata)
reinit_device(cgpu);
}
}
rd_unlock(&mining_thr_lock);
}
return NULL;
@ -8122,6 +8125,10 @@ static void restart_mining_threads(unsigned int new_n_threads)
thr->cgpu->drv->thread_shutdown(thr);
thr->cgpu->shutdown = false;
}
}
rd_lock(&mining_thr_lock);
if (mining_thr) {
for (i = 0; i < total_devices; ++i) {
free(devices[i]->thr);
}
@ -8159,14 +8166,26 @@ static void restart_mining_threads(unsigned int new_n_threads)
thr->cgpu = cgpu;
thr->device_thread = j;
cgtime(&thr->last);
cgpu->thr[j] = thr;
}
}
rd_unlock(&mining_thr_lock);
for (i = 0; i < total_devices; ++i) {
struct cgpu_info *cgpu = devices[i];
for (j = 0; j < cgpu->threads; ++j) {
thr = cgpu->thr[j];
if (!cgpu->drv->thread_prepare(thr))
continue;
if (unlikely(thr_info_create(thr, NULL, miner_thread, thr)))
quit(1, "thread %d create failed", thr->id);
cgpu->thr[j] = thr;
/* Enable threads for devices set not to mine but disable
* their queue in case we wish to enable them later */
if (cgpu->deven != DEV_DISABLED) {