Fixed coverity issue

pull/206/head
SChernykh 2022-08-05 15:27:39 +02:00
parent 3dde71f1ff
commit 948436e57e
1 changed files with 26 additions and 19 deletions

View File

@ -2011,29 +2011,36 @@ void SideChain::finish_precalc()
return; return;
} }
try
{ {
MutexLock lock(m_precalcJobsMutex); {
for (PrecalcJob* job : m_precalcJobs) { MutexLock lock(m_precalcJobsMutex);
delete job; for (PrecalcJob* job : m_precalcJobs) {
delete job;
}
m_precalcJobs.clear();
m_precalcJobs.shrink_to_fit();
uv_cond_broadcast(&m_precalcJobsCond);
} }
m_precalcJobs.clear();
m_precalcJobs.shrink_to_fit(); for (std::thread& t : m_precalcWorkers) {
uv_cond_broadcast(&m_precalcJobsCond); t.join();
}
m_precalcWorkers.clear();
m_precalcWorkers.shrink_to_fit();
delete m_uniquePrecalcInputs;
m_uniquePrecalcInputs = nullptr;
uv_mutex_destroy(&m_precalcJobsMutex);
uv_cond_destroy(&m_precalcJobsCond);
LOGINFO(4, "pre-calculation workers stopped");
} }
catch (const std::exception& e)
for (std::thread& t : m_precalcWorkers) { {
t.join(); LOGERR(1, "exception in finish_precalc(): " << e.what());
} }
m_precalcWorkers.clear();
m_precalcWorkers.shrink_to_fit();
delete m_uniquePrecalcInputs;
m_uniquePrecalcInputs = nullptr;
uv_mutex_destroy(&m_precalcJobsMutex);
uv_cond_destroy(&m_precalcJobsCond);
LOGINFO(4, "pre-calculation workers stopped");
} }
} // namespace p2pool } // namespace p2pool