Skip to content

Commit

Permalink
Fixed data race
Browse files Browse the repository at this point in the history
  • Loading branch information
SChernykh committed Dec 17, 2024
1 parent 92dfde8 commit dd2812f
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/stratum_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,10 @@ void StratumServer::update_hashrate_data(uint64_t hashes, uint64_t timestamp)

WriteLock lock(m_hashrateDataLock);

m_cumulativeHashes += hashes;
if (hashes) {
m_cumulativeHashes += hashes;
++m_totalStratumShares;
}

HashrateData* data = m_hashrateData;
HashrateData& head = data[m_hashrateDataHead];
Expand Down Expand Up @@ -1094,10 +1097,6 @@ void StratumServer::on_after_share_found(uv_work_t* req, int /*status*/)
server->ban(share->m_clientIPv6, share->m_clientAddr, DEFAULT_BAN_TIME);
}

if (share->m_result == SubmittedShare::Result::OK) {
++server->m_totalStratumShares;
}

if (share->m_allocated) {
auto it = std::find(server->m_pendingShareChecks.begin(), server->m_pendingShareChecks.end(), share);
if (it != server->m_pendingShareChecks.end()) {
Expand Down

0 comments on commit dd2812f

Please sign in to comment.