diff --git a/CHANGELOG.md b/CHANGELOG.md index 38ac7b77..dce82107 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,10 @@ - [#268](https://github.com/xmrig/xmrig-amd/pull/268) [#270](https://github.com/xmrig/xmrig-amd/pull/270) [#271](https://github.com/xmrig/xmrig-amd/pull/271) [#273](https://github.com/xmrig/xmrig-amd/pull/273) [#274](https://github.com/xmrig/xmrig-amd/pull/274) [#1171](https://github.com/xmrig/xmrig/pull/1171) Added RandomX support for OpenCL, thanks [@SChernykh](https://github.com/SChernykh). - Algorithm `cn/wow` removed, as no longer alive. +# 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/Console.cpp b/src/base/io/Console.cpp index 0e5cd269..bba73035 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 c0a36ec4..0a075348 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 a5b6c1a7..34a7d66b 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 90e4fa14..6277cc7b 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; };