From f6752310b49386b0bd639b2f5ea5484b1ec22b80 Mon Sep 17 00:00:00 2001 From: XMRig Date: Fri, 20 Sep 2019 14:54:18 +0700 Subject: [PATCH] Backport fixes from v4. --- CHANGELOG.md | 4 ++++ src/base/io/json/Json_win.cpp | 3 ++- src/core/Miner.cpp | 11 +++++------ src/crypto/common/Nonce.cpp | 1 - 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 30e533594..0a3cda0cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# v3.1.3 +- [#1180](https://github.com/xmrig/xmrig/issues/1180) Fixed possible duplicated shares after algorithm switching. +- Fixed wrong config file permissions after write (only gcc builds on recent Windows 10 affected). + # v3.1.2 - Many RandomX optimizations and fixes. - [#1132](https://github.com/xmrig/xmrig/issues/1132) Fixed build on CentOS 7. diff --git a/src/base/io/json/Json_win.cpp b/src/base/io/json/Json_win.cpp index 73aff2c59..cb6f02f64 100644 --- a/src/base/io/json/Json_win.cpp +++ b/src/base/io/json/Json_win.cpp @@ -28,6 +28,7 @@ #ifdef __GNUC__ # include +# include # include #endif @@ -102,7 +103,7 @@ bool xmrig::Json::save(const char *fileName, const rapidjson::Document &doc) return false; } # elif defined(__GNUC__) - const int fd = _wopen(toUtf16(fileName).c_str(), _O_WRONLY | _O_BINARY | _O_CREAT | _O_TRUNC); + const int fd = _wopen(toUtf16(fileName).c_str(), _O_WRONLY | _O_BINARY | _O_CREAT | _O_TRUNC, _S_IWRITE); if (fd == -1) { return false; } diff --git a/src/core/Miner.cpp b/src/core/Miner.cpp index 26a5d7e75..b1b0bf9c6 100644 --- a/src/core/Miner.cpp +++ b/src/core/Miner.cpp @@ -112,16 +112,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(); }