mirror of
https://github.com/SChernykh/p2pool.git
synced 2024-12-22 19:39:22 +00:00
Fixed a potential deadlock
This commit is contained in:
parent
658d756120
commit
9015106ca2
1 changed files with 32 additions and 31 deletions
|
@ -346,16 +346,17 @@ void p2pool::handle_miner_data(MinerData& data)
|
|||
cleanup_mainchain_data(data.height);
|
||||
}
|
||||
|
||||
update_aux_data(hash());
|
||||
|
||||
data.tx_backlog.clear();
|
||||
data.time_received = std::chrono::high_resolution_clock::now();
|
||||
{
|
||||
WriteLock lock(m_minerDataLock);
|
||||
data.aux_chains = m_minerData.aux_chains;
|
||||
data.aux_nonce = m_minerData.aux_nonce;
|
||||
m_minerData = data;
|
||||
}
|
||||
m_updateSeed = true;
|
||||
update_median_timestamp();
|
||||
update_aux_data(hash());
|
||||
|
||||
const Params::Host& host = current_host();
|
||||
|
||||
|
@ -506,16 +507,9 @@ void p2pool::handle_chain_main(ChainMain& data, const char* extra)
|
|||
|
||||
void p2pool::update_aux_data(const hash& chain_id)
|
||||
{
|
||||
MinerData data;
|
||||
{
|
||||
WriteLock lock(m_minerDataLock);
|
||||
|
||||
MinerData& data = m_minerData;
|
||||
|
||||
const std::vector<AuxChainData> old_data = data.aux_chains;
|
||||
data.aux_chains.clear();
|
||||
|
||||
{
|
||||
ReadLock lock2(m_mergeMiningClientsLock);
|
||||
ReadLock lock(m_mergeMiningClientsLock);
|
||||
|
||||
if (!m_mergeMiningClients.empty()) {
|
||||
data.aux_chains.reserve(m_mergeMiningClients.size());
|
||||
|
@ -537,9 +531,16 @@ void p2pool::update_aux_data(const hash& chain_id)
|
|||
}
|
||||
}
|
||||
|
||||
if (old_data == data.aux_chains) {
|
||||
{
|
||||
WriteLock lock(m_minerDataLock);
|
||||
|
||||
if ((m_minerData.aux_nonce == data.aux_nonce) && (m_minerData.aux_chains == data.aux_chains)) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_minerData.aux_chains = data.aux_chains;
|
||||
m_minerData.aux_nonce = data.aux_nonce;
|
||||
LOGINFO(5, "update_aux_data: n_aux_chains = " << m_minerData.aux_chains.size() << ", aux_nonce = " << m_minerData.aux_nonce);
|
||||
}
|
||||
|
||||
if (!chain_id.empty()) {
|
||||
|
|
Loading…
Reference in a new issue