Auto merge of #3647 - LarryRuane:2926-mutex-assert-stop, r=str4d

On shutdown, wait for miner threads to exit (join them)

Closes #2926. Have `Shutdown()` running in the main thread wait for miner threads to exit before exiting.
This commit is contained in:
Homu 2019-01-03 08:49:16 -08:00
commit 8df7a073ce
1 changed files with 4 additions and 2 deletions

View File

@ -640,10 +640,11 @@ void static BitcoinMiner()
LogPrintf("ZcashMiner:\n"); LogPrintf("ZcashMiner:\n");
LogPrintf("proof-of-work found \n hash: %s \ntarget: %s\n", pblock->GetHash().GetHex(), hashTarget.GetHex()); LogPrintf("proof-of-work found \n hash: %s \ntarget: %s\n", pblock->GetHash().GetHex(), hashTarget.GetHex());
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
if (ProcessBlockFound(pblock, *pwallet, reservekey)) { if (ProcessBlockFound(pblock, *pwallet, reservekey))
#else #else
if (ProcessBlockFound(pblock)) { if (ProcessBlockFound(pblock))
#endif #endif
{
// Ignore chain updates caused by us // Ignore chain updates caused by us
std::lock_guard<std::mutex> lock{m_cs}; std::lock_guard<std::mutex> lock{m_cs};
cancelSolver = false; cancelSolver = false;
@ -767,6 +768,7 @@ void GenerateBitcoins(bool fGenerate, int nThreads)
if (minerThreads != NULL) if (minerThreads != NULL)
{ {
minerThreads->interrupt_all(); minerThreads->interrupt_all();
minerThreads->join_all();
delete minerThreads; delete minerThreads;
minerThreads = NULL; minerThreads = NULL;
} }