Fixed potential deadlock

Can't lock `m_minerLock` inside SideChain update
This commit is contained in:
SChernykh
2022-07-14 13:14:20 +02:00
parent 0e7c1aa481
commit 3c697c2d7e
3 changed files with 17 additions and 16 deletions
+13 -10
View File
@@ -596,13 +596,15 @@ void p2pool::submit_sidechain_block(uint32_t template_id, uint32_t nonce, uint32
m_blockTemplate->submit_sidechain_block(template_id, nonce, extra_nonce);
}
void p2pool::update_block_template_async()
void p2pool::update_block_template_async(bool is_alternative_block)
{
// If p2pool is stopped, m_blockTemplateAsync is most likely already closed
if (m_stopped) {
return;
}
m_isAlternativeBlock = is_alternative_block;
const int err = uv_async_send(&m_blockTemplateAsync);
if (err) {
LOGERR(1, "uv_async_send failed, error " << uv_err_name(err));
@@ -620,6 +622,16 @@ void p2pool::update_block_template()
m_blockTemplate->update(data, *m_mempool, &m_params->m_wallet);
stratum_on_block();
api_update_pool_stats();
#ifdef WITH_RANDOMX
if (m_isAlternativeBlock.exchange(false)) {
MutexLock lock(m_minerLock);
if (m_miner) {
m_miner->reset_share_counters();
}
}
#endif
}
void p2pool::download_block_headers(uint64_t current_height)
@@ -1373,15 +1385,6 @@ void p2pool::stop_mining()
m_miner = nullptr;
}
}
void p2pool::reset_miner()
{
MutexLock lock(m_minerLock);
if (m_miner) {
m_miner->reset_share_counters();
}
}
#endif
static void on_signal(uv_signal_t* handle, int signum)