From 365667ee0af2e122adac56a36ac6b4ce8cb3be2f Mon Sep 17 00:00:00 2001 From: XMRig Date: Fri, 20 Sep 2019 00:30:20 +0700 Subject: [PATCH] #1180 Fixed race condition in nonce reset. --- src/core/Miner.cpp | 11 +++++------ src/crypto/common/Nonce.cpp | 1 - 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/core/Miner.cpp b/src/core/Miner.cpp index d382d7aaa..d53724222 100644 --- a/src/core/Miner.cpp +++ b/src/core/Miner.cpp @@ -124,16 +124,15 @@ public: { active = true; + if (reset) { + Nonce::reset(job.index()); + } + for (IBackend *backend : backends) { backend->setJob(job); } - if (reset) { - Nonce::reset(job.index()); - } - else { - Nonce::touch(); - } + Nonce::touch(); if (enabled) { Nonce::pause(false);; diff --git a/src/crypto/common/Nonce.cpp b/src/crypto/common/Nonce.cpp index 151819e0d..e79cb310e 100644 --- a/src/crypto/common/Nonce.cpp +++ b/src/crypto/common/Nonce.cpp @@ -78,7 +78,6 @@ void xmrig::Nonce::reset(uint8_t index) std::lock_guard lock(mutex); m_nonces[index] = 0; - touch(); }