From 171762d1aa321d6856f5cbdc1e09b413b32eda5d Mon Sep 17 00:00:00 2001 From: XMRig Date: Sun, 15 Sep 2019 18:04:18 +0700 Subject: [PATCH 1/6] v3.1.2 --- src/version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/version.h b/src/version.h index a0c461cfe..1bbb14ac0 100644 --- a/src/version.h +++ b/src/version.h @@ -28,7 +28,7 @@ #define APP_ID "xmrig" #define APP_NAME "XMRig" #define APP_DESC "XMRig CPU miner" -#define APP_VERSION "3.1.2-dev" +#define APP_VERSION "3.1.2" #define APP_DOMAIN "xmrig.com" #define APP_SITE "www.xmrig.com" #define APP_COPYRIGHT "Copyright (C) 2016-2019 xmrig.com" From 1cd1f13feea3febab76883768ef351df2e201794 Mon Sep 17 00:00:00 2001 From: XMRig Date: Mon, 16 Sep 2019 00:29:46 +0700 Subject: [PATCH 2/6] v3.1.3-dev --- src/version.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/version.h b/src/version.h index 1bbb14ac0..3529e72c4 100644 --- a/src/version.h +++ b/src/version.h @@ -28,7 +28,7 @@ #define APP_ID "xmrig" #define APP_NAME "XMRig" #define APP_DESC "XMRig CPU miner" -#define APP_VERSION "3.1.2" +#define APP_VERSION "3.1.3-dev" #define APP_DOMAIN "xmrig.com" #define APP_SITE "www.xmrig.com" #define APP_COPYRIGHT "Copyright (C) 2016-2019 xmrig.com" @@ -36,7 +36,7 @@ #define APP_VER_MAJOR 3 #define APP_VER_MINOR 1 -#define APP_VER_PATCH 2 +#define APP_VER_PATCH 3 #ifdef _MSC_VER # if (_MSC_VER >= 1920) From f6752310b49386b0bd639b2f5ea5484b1ec22b80 Mon Sep 17 00:00:00 2001 From: XMRig Date: Fri, 20 Sep 2019 14:54:18 +0700 Subject: [PATCH 3/6] 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(); } From 05b2c66aafae9156611b61bbe2a607a2ac11aeec Mon Sep 17 00:00:00 2001 From: XMRig Date: Fri, 20 Sep 2019 15:02:20 +0700 Subject: [PATCH 4/6] v3.1.3 --- src/version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/version.h b/src/version.h index 3529e72c4..151e925b2 100644 --- a/src/version.h +++ b/src/version.h @@ -28,7 +28,7 @@ #define APP_ID "xmrig" #define APP_NAME "XMRig" #define APP_DESC "XMRig CPU miner" -#define APP_VERSION "3.1.3-dev" +#define APP_VERSION "3.1.3" #define APP_DOMAIN "xmrig.com" #define APP_SITE "www.xmrig.com" #define APP_COPYRIGHT "Copyright (C) 2016-2019 xmrig.com" From 7a1ff6bfed6a4118e77ddb0b13b7bde4951abc2e Mon Sep 17 00:00:00 2001 From: XMRig Date: Fri, 20 Sep 2019 16:45:17 +0700 Subject: [PATCH 5/6] v3.1.4-dev --- src/version.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/version.h b/src/version.h index 151e925b2..81e2bccea 100644 --- a/src/version.h +++ b/src/version.h @@ -28,7 +28,7 @@ #define APP_ID "xmrig" #define APP_NAME "XMRig" #define APP_DESC "XMRig CPU miner" -#define APP_VERSION "3.1.3" +#define APP_VERSION "3.1.4-dev" #define APP_DOMAIN "xmrig.com" #define APP_SITE "www.xmrig.com" #define APP_COPYRIGHT "Copyright (C) 2016-2019 xmrig.com" @@ -36,7 +36,7 @@ #define APP_VER_MAJOR 3 #define APP_VER_MINOR 1 -#define APP_VER_PATCH 3 +#define APP_VER_PATCH 4 #ifdef _MSC_VER # if (_MSC_VER >= 1920) From e57798360fe344d72b1bddfa2637472c16b63057 Mon Sep 17 00:00:00 2001 From: XMRig Date: Sat, 21 Sep 2019 03:22:19 +0700 Subject: [PATCH 6/6] #1183 Disable stdin handler if not available. --- src/base/io/Console.cpp | 16 +++++++- src/base/io/Console.h | 12 ++++-- src/base/io/log/backends/ConsoleLog.cpp | 22 ++++++++--- src/base/io/log/backends/ConsoleLog.h | 12 ++++-- src/base/tools/Object.h | 52 +++++++++++++++++++++++++ 5 files changed, 100 insertions(+), 14 deletions(-) create mode 100644 src/base/tools/Object.h diff --git a/src/base/io/Console.cpp b/src/base/io/Console.cpp index 0e5cd2696..bba73035a 100644 --- a/src/base/io/Console.cpp +++ b/src/base/io/Console.cpp @@ -31,8 +31,11 @@ xmrig::Console::Console(IConsoleListener *listener) : m_listener(listener) { - m_tty = new uv_tty_t; + if (!isSupported()) { + return; + } + m_tty = new uv_tty_t; m_tty->data = this; uv_tty_init(uv_default_loop(), m_tty, 0, 1); @@ -53,6 +56,10 @@ xmrig::Console::~Console() void xmrig::Console::stop() { + if (!m_tty) { + return; + } + uv_tty_reset_mode(); Handle::close(m_tty); @@ -60,6 +67,13 @@ void xmrig::Console::stop() } +bool xmrig::Console::isSupported() const +{ + const uv_handle_type type = uv_guess_handle(0); + return type == UV_TTY || type == UV_NAMED_PIPE; +} + + void xmrig::Console::onAllocBuffer(uv_handle_t *handle, size_t, uv_buf_t *buf) { auto console = static_cast(handle->data); diff --git a/src/base/io/Console.h b/src/base/io/Console.h index c0a36ec4f..0a075348b 100644 --- a/src/base/io/Console.h +++ b/src/base/io/Console.h @@ -26,9 +26,11 @@ #define XMRIG_CONSOLE_H -#include +#include "base/tools/Object.h" +#include + namespace xmrig { @@ -39,18 +41,22 @@ class IConsoleListener; class Console { public: + XMRIG_DISABLE_COPY_MOVE_DEFAULT(Console) + Console(IConsoleListener *listener); ~Console(); void stop(); private: + bool isSupported() const; + static void onAllocBuffer(uv_handle_t *handle, size_t suggested_size, uv_buf_t *buf); static void onRead(uv_stream_t *stream, ssize_t nread, const uv_buf_t *buf); - char m_buf[1]; + char m_buf[1] = { 0 }; IConsoleListener *m_listener; - uv_tty_t *m_tty; + uv_tty_t *m_tty = nullptr; }; diff --git a/src/base/io/log/backends/ConsoleLog.cpp b/src/base/io/log/backends/ConsoleLog.cpp index a5b6c1a7d..34a7d66ba 100644 --- a/src/base/io/log/backends/ConsoleLog.cpp +++ b/src/base/io/log/backends/ConsoleLog.cpp @@ -24,7 +24,7 @@ */ -#include +#include #include "base/tools/Handle.h" @@ -32,9 +32,13 @@ #include "base/io/log/Log.h" -xmrig::ConsoleLog::ConsoleLog() : - m_stream(nullptr) +xmrig::ConsoleLog::ConsoleLog() { + if (!isSupported()) { + Log::colors = false; + return; + } + m_tty = new uv_tty_t; if (uv_tty_init(uv_default_loop(), m_tty, 1, 0) < 0) { @@ -66,7 +70,7 @@ xmrig::ConsoleLog::~ConsoleLog() void xmrig::ConsoleLog::print(int, const char *line, size_t, size_t size, bool colors) { - if (Log::colors != colors) { + if (!m_tty || Log::colors != colors) { return; } @@ -86,12 +90,18 @@ void xmrig::ConsoleLog::print(int, const char *line, size_t, size_t size, bool c } +bool xmrig::ConsoleLog::isSupported() const +{ + const uv_handle_type type = uv_guess_handle(1); + return type == UV_TTY || type == UV_NAMED_PIPE; +} + + bool xmrig::ConsoleLog::isWritable() const { if (!m_stream || uv_is_writable(m_stream) != 1) { return false; } - const uv_handle_type type = uv_guess_handle(1); - return type == UV_TTY || type == UV_NAMED_PIPE; + return isSupported(); } diff --git a/src/base/io/log/backends/ConsoleLog.h b/src/base/io/log/backends/ConsoleLog.h index 90e4fa148..6277cc7be 100644 --- a/src/base/io/log/backends/ConsoleLog.h +++ b/src/base/io/log/backends/ConsoleLog.h @@ -27,11 +27,12 @@ #define XMRIG_CONSOLELOG_H -typedef struct uv_stream_s uv_stream_t; -typedef struct uv_tty_s uv_tty_t; +using uv_stream_t = struct uv_stream_s; +using uv_tty_t = struct uv_tty_s; #include "base/kernel/interfaces/ILogBackend.h" +#include "base/tools/Object.h" namespace xmrig { @@ -40,6 +41,8 @@ namespace xmrig { class ConsoleLog : public ILogBackend { public: + XMRIG_DISABLE_COPY_MOVE(ConsoleLog) + ConsoleLog(); ~ConsoleLog() override; @@ -47,10 +50,11 @@ protected: void print(int level, const char *line, size_t offset, size_t size, bool colors) override; private: + bool isSupported() const; bool isWritable() const; - uv_stream_t *m_stream; - uv_tty_t *m_tty; + uv_stream_t *m_stream = nullptr; + uv_tty_t *m_tty = nullptr; }; diff --git a/src/base/tools/Object.h b/src/base/tools/Object.h new file mode 100644 index 000000000..7e460e444 --- /dev/null +++ b/src/base/tools/Object.h @@ -0,0 +1,52 @@ +/* XMRig + * Copyright 2010 Jeff Garzik + * Copyright 2012-2014 pooler + * Copyright 2014 Lucas Jones + * Copyright 2014-2016 Wolf9466 + * Copyright 2016 Jay D Dee + * Copyright 2017-2018 XMR-Stak , + * Copyright 2018-2019 SChernykh + * Copyright 2016-2019 XMRig , + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef XMRIG_OBJECT_H +#define XMRIG_OBJECT_H + + +#include + + +namespace xmrig { + + +#define XMRIG_DISABLE_COPY_MOVE(X) \ + X(const X &other) = delete; \ + X(X &&other) = delete; \ + X &operator=(const X &other) = delete; \ + X &operator=(X &&other) = delete; + + +#define XMRIG_DISABLE_COPY_MOVE_DEFAULT(X) \ + X() = delete; \ + X(const X &other) = delete; \ + X(X &&other) = delete; \ + X &operator=(const X &other) = delete; \ + X &operator=(X &&other) = delete; + + +} /* namespace xmrig */ + +#endif /* XMRIG_OBJECT_H */