mirror of
https://github.com/xmrig/xmrig.git
synced 2025-12-11 17:32:47 -05:00
Fix possible race condition in hashrate counting code
Use single atomic operation to switch between data points.
This commit is contained in:
@@ -143,11 +143,11 @@ void xmrig::Workers<T>::tick(uint64_t)
|
||||
}
|
||||
|
||||
for (Thread<T> *handle : m_workers) {
|
||||
if (!handle->worker()) {
|
||||
continue;
|
||||
if (handle->worker()) {
|
||||
uint64_t hashCount, timeStamp;
|
||||
handle->worker()->getHashrateData(hashCount, timeStamp);
|
||||
d_ptr->hashrate->add(handle->id(), hashCount, timeStamp);
|
||||
}
|
||||
|
||||
d_ptr->hashrate->add(handle->id(), handle->worker()->hashCount(), handle->worker()->timestamp());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user