Fix possible race condition in hashrate counting code

Use single atomic operation to switch between data points.
This commit is contained in:
SChernykh 2020-10-09 10:29:18 +02:00
parent d9b6f46a6a
commit a4550f55ea
4 changed files with 35 additions and 21 deletions

View file

@ -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());
}
}