Merge pull request #5288

39f000b3 miner: fix possible exit crash due to race in stop (moneromooo-monero)
This commit is contained in:
Riccardo Spagni 2019-04-01 17:20:25 +02:00
commit 574c399386
No known key found for this signature in database
GPG Key ID: 55432DF31CCD4FCD
1 changed files with 3 additions and 2 deletions

View File

@ -435,14 +435,15 @@ namespace cryptonote
{ {
MTRACE("Miner has received stop signal"); MTRACE("Miner has received stop signal");
if (!is_mining()) CRITICAL_REGION_LOCAL(m_threads_lock);
bool mining = !m_threads.empty();
if (!mining)
{ {
MTRACE("Not mining - nothing to stop" ); MTRACE("Not mining - nothing to stop" );
return true; return true;
} }
send_stop_signal(); send_stop_signal();
CRITICAL_REGION_LOCAL(m_threads_lock);
// In case background mining was active and the miner threads are waiting // In case background mining was active and the miner threads are waiting
// on the background miner to signal start. // on the background miner to signal start.