summaryrefslogtreecommitdiffstats
path: root/xmrstak/backend/globalStates.cpp
diff options
context:
space:
mode:
authorpsychocrypt <psychocryptHPC@gmail.com>2018-05-22 23:05:46 +0200
committerTimothy Pearson <tpearson@raptorengineering.com>2018-06-04 21:07:11 +0000
commit34098ee5546d34068ae16963b9e875fd78e215f9 (patch)
tree83a6c348a40838dc399373c1058024fb76d0f74d /xmrstak/backend/globalStates.cpp
parent22732aa90e8eb1219691875b4019257535cff462 (diff)
downloadxmr-stak-34098ee5546d34068ae16963b9e875fd78e215f9.zip
xmr-stak-34098ee5546d34068ae16963b9e875fd78e215f9.tar.gz
fix duplicated nonce usage
- avoid that a nonce which not fits to the current job is used (check jobId after start nonce is consumed) - move jobId check into the if condition to get a new bunch of nonces - CPU: add jobId validation after the start nonce is consumed
Diffstat (limited to 'xmrstak/backend/globalStates.cpp')
-rw-r--r--xmrstak/backend/globalStates.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/xmrstak/backend/globalStates.cpp b/xmrstak/backend/globalStates.cpp
index 9f41be2..3bd7d0e 100644
--- a/xmrstak/backend/globalStates.cpp
+++ b/xmrstak/backend/globalStates.cpp
@@ -47,20 +47,21 @@ void globalStates::switch_work(miner_work& pWork, pool_data& dat)
{
jobLock.WriteLock();
+ /* This notifies all threads that the job has changed.
+ * To avoid duplicated shared this must be done before the nonce is exchanged.
+ */
+ iGlobalJobNo++;
+
size_t xid = dat.pool_id;
dat.pool_id = pool_id;
pool_id = xid;
/* Maybe a worker thread is updating the nonce while we read it.
- * In that case GPUs check the job ID after a nonce update and in the
- * case that it is a CPU thread we have a small chance (max 6 nonces per CPU thread)
- * that we recalculate a nonce after we reconnect to the current pool
+ * To avoid duplicated share calculations the job ID is checked in the worker thread
+ * after the nonce is read.
*/
dat.iSavedNonce = iGlobalNonce.exchange(dat.iSavedNonce, std::memory_order_relaxed);
oGlobalWork = pWork;
-
- // this notifies all threads that the job has changed
- iGlobalJobNo++;
jobLock.UnLock();
}
OpenPOWER on IntegriCloud