Fix TSan race on m_p2pServer during startup, update curl to 8.18.0

This commit is contained in:
Matt Hess
2026-01-12 21:48:10 +00:00
parent 67573992d2
commit 6c8b8894ee
4 changed files with 21 additions and 11 deletions

View File

@@ -3394,6 +3394,7 @@ bool P2PServer::P2PClient::on_checkpoint_response(const uint8_t* buf, uint32_t c
const uint8_t* p = buf;
for (uint32_t i = 0; i < count; ++i) {
Checkpoint cp;
cp.mainchain_height = 0; // Not sent over wire, initialize to 0
// Height
cp.height = read_unaligned(reinterpret_cast<const uint64_t*>(p));

View File

@@ -696,7 +696,9 @@ void p2pool::handle_chain_main(ChainMain& data, const char* extra, const std::ve
void p2pool::handle_monero_block_broadcast(std::vector<std::vector<uint8_t>>&& blobs)
{
m_p2pServer->broadcast_monero_block_async(std::move(blobs));
if (P2PServer* server = m_p2pServer.load()) {
server->broadcast_monero_block_async(std::move(blobs));
}
}
#ifdef WITH_MERGE_MINING_DONATION
@@ -912,7 +914,9 @@ void p2pool::send_aux_job_donation()
job.insert(job.end(), signature, signature + sizeof(signature));
m_p2pServer->broadcast_aux_job_donation_async(job.data(), static_cast<uint32_t>(job.size()), timestamp);
if (P2PServer* server = m_p2pServer.load()) {
server->broadcast_aux_job_donation_async(job.data(), static_cast<uint32_t>(job.size()), timestamp);
}
#else
LOGERR(1, "p2pool::send_aux_job_donation() must be built with TLS");
#endif
@@ -1209,7 +1213,9 @@ void p2pool::submit_block() const
hash digest;
sha256(blob.data(), static_cast<uint32_t>(blob.size()), digest.h);
m_p2pServer->store_monero_block_broadcast(digest);
if (P2PServer* server = m_p2pServer.load()) {
server->store_monero_block_broadcast(digest);
}
const Params::Host& host = current_host();
@@ -1447,7 +1453,7 @@ void p2pool::download_block_headers4(uint64_t start_height, uint64_t current_hei
LOGINFO(0, log::LightCyan() << "LOADING SIDECHAIN - MINING MAY NOT OCCUR UNTIL COMPLETE");
LOGINFO(0, log::LightCyan() << "########################################################");
m_p2pServer = new P2PServer(this);
m_p2pServer.store(new P2PServer(this));
// Wait for sidechain to be ready before starting stratum/mining
int genesis_wait_count = 0;
@@ -1457,7 +1463,8 @@ void p2pool::download_block_headers4(uint64_t start_height, uint64_t current_hei
genesis_wait_count++;
// Genesis node escape: if we created genesis and have no peers, proceed
if (m_p2pServer && m_p2pServer->num_connections() == 0 && genesis_wait_count >= 6) {
P2PServer* server = m_p2pServer.load();
if (server && server->num_connections() == 0 && genesis_wait_count >= 6) {
LOGINFO(0, log::LightGreen() << "########################################");
LOGINFO(0, log::LightGreen() << "GENESIS NODE - MINING IS NOW ENABLED");
LOGINFO(0, log::LightGreen() << "########################################");
@@ -2148,7 +2155,8 @@ void p2pool::api_update_pool_stats()
const difficulty_type diff = m_sideChain->difficulty();
const uint64_t height = tip ? tip->m_sidechainHeight : 0;
const uint64_t hashrate = udiv128(diff.hi, diff.lo, m_sideChain->block_time(), &t);
const uint64_t miners = std::max<uint64_t>(m_sideChain->miner_count(), m_p2pServer ? m_p2pServer->peer_list_size() : 0U);
P2PServer* p2p = m_p2pServer.load();
const uint64_t miners = std::max<uint64_t>(m_sideChain->miner_count(), p2p ? p2p->peer_list_size() : 0U);
const difficulty_type total_hashes = m_sideChain->total_hashes();
const auto& s = m_blockTemplate->shares();
@@ -2226,7 +2234,8 @@ void p2pool::api_update_stats_mod()
s << last_block_found_hash << '\0';
memcpy(last_block_found_buf + 4, "...", 4);
const uint64_t miners = std::max<uint64_t>(m_sideChain->miner_count(), m_p2pServer ? m_p2pServer->peer_list_size() : 0U);
P2PServer* p2p_status = m_p2pServer.load();
const uint64_t miners = std::max<uint64_t>(m_sideChain->miner_count(), p2p_status ? p2p_status->peer_list_size() : 0U);
uint64_t t;
const difficulty_type& diff = m_sideChain->difficulty();
@@ -2604,7 +2613,7 @@ int p2pool::run()
}
#endif
delete m_stratumServer;
delete m_p2pServer;
delete m_p2pServer.load();
LOGINFO(1, "stopped");
return 0;

View File

@@ -76,7 +76,7 @@ public:
bool get_seed(uint64_t height, hash& seed) const;
StratumServer* stratum_server() const { return m_stratumServer; }
P2PServer* p2p_server() const { return m_p2pServer; }
P2PServer* p2p_server() const { return m_p2pServer.load(); }
#if defined(WITH_RANDOMX) && !defined(P2POOL_UNIT_TESTS)
void print_miner_status();
@@ -229,7 +229,7 @@ private:
std::atomic<uint32_t> m_serversStarted{ 0 };
StratumServer* m_stratumServer = nullptr;
P2PServer* m_p2pServer = nullptr;
std::atomic<P2PServer*> m_p2pServer{ nullptr };
std::atomic<bool> m_startupFinished{ false };