Skip to content
Snippets Groups Projects
Commit b64d5851 authored by psychocrypt's avatar psychocrypt Committed by GitHub
Browse files

Merge pull request #254 from fireice-uk/topic-race-fix

Race condition fix
parents 238a513a c2203be4
No related branches found
No related tags found
No related merge requests found
......@@ -161,6 +161,7 @@ minethd::minethd(miner_work& pWork, size_t iNo, bool double_work, bool no_prefet
bNoPrefetch = no_prefetch;
this->affinity = affinity;
std::lock_guard<std::mutex> lock(work_thd_mtx);
if(double_work)
oWorkThd = std::thread(&minethd::double_work_main, this);
else
......@@ -363,6 +364,9 @@ minethd::cn_hash_fun minethd::func_selector(bool bHaveAes, bool bNoPrefetch)
void minethd::pin_thd_affinity()
{
//Lock is needed because we need to use oWorkThd
std::lock_guard<std::mutex> lock(work_thd_mtx);
// pin memory to NUMA node
bindMemoryToNUMANode(affinity);
......
#pragma once
#include <thread>
#include <atomic>
#include <mutex>
#include "crypto/cryptonight.h"
class telemetry
......@@ -130,6 +131,8 @@ private:
miner_work oWork;
void pin_thd_affinity();
// Held by the creating context to prevent a race cond with oWorkThd = std::thread(...)
std::mutex work_thd_mtx;
std::thread oWorkThd;
uint8_t iThreadNo;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment