diff --git a/CMakeLists.txt b/CMakeLists.txt index 41e809a40..3eb8a0fcf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,6 +21,10 @@ set(HEADERS src/api/NetworkState.h src/App.h src/base/io/Json.h + src/base/io/Watcher.h + src/base/kernel/interfaces/IConfigListener.h + src/base/kernel/interfaces/IWatcherListener.h + src/base/tools/Handle.h src/base/tools/String.h src/common/config/CommonConfig.h src/common/config/ConfigLoader.h @@ -38,7 +42,6 @@ set(HEADERS src/common/interfaces/ILogBackend.h src/common/interfaces/IStrategy.h src/common/interfaces/IStrategyListener.h - src/common/interfaces/IWatcherListener.h src/common/log/BasicLog.h src/common/log/ConsoleLog.h src/common/log/FileLog.h @@ -100,6 +103,8 @@ set(SOURCES src/api/NetworkState.cpp src/App.cpp src/base/io/Json.cpp + src/base/io/Watcher.cpp + src/base/tools/Handle.cpp src/base/tools/String.cpp src/common/config/CommonConfig.cpp src/common/config/ConfigLoader.cpp diff --git a/src/base/io/Watcher.cpp b/src/base/io/Watcher.cpp new file mode 100644 index 000000000..93b666431 --- /dev/null +++ b/src/base/io/Watcher.cpp @@ -0,0 +1,94 @@ +/* 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 . + */ + + +#include + + +#include "base/kernel/interfaces/IWatcherListener.h" +#include "base/io/Watcher.h" +#include "base/tools/Handle.h" + + +xmrig::Watcher::Watcher(const String &path, IWatcherListener *listener) : + m_listener(listener), + m_path(path) +{ + m_fsEvent = new uv_fs_event_t; + uv_fs_event_init(uv_default_loop(), m_fsEvent); + + m_timer = new uv_timer_t; + uv_timer_init(uv_default_loop(), m_timer); + + m_fsEvent->data = m_timer->data = this; + + start(); +} + + +xmrig::Watcher::~Watcher() +{ + Handle::close(m_timer); + Handle::close(m_fsEvent); +} + + +void xmrig::Watcher::onTimer(uv_timer_t *handle) +{ + static_cast(handle->data)->reload(); +} + + +void xmrig::Watcher::onFsEvent(uv_fs_event_t *handle, const char *filename, int, int) +{ + if (!filename) { + return; + } + + static_cast(handle->data)->queueUpdate(); +} + + +void xmrig::Watcher::queueUpdate() +{ + uv_timer_stop(m_timer); + uv_timer_start(m_timer, xmrig::Watcher::onTimer, kDelay, 0); +} + + +void xmrig::Watcher::reload() +{ + m_listener->onFileChanged(m_path); + +# ifndef _WIN32 + uv_fs_event_stop(&m_fsEvent); + start(); +# endif +} + + +void xmrig::Watcher::start() +{ + uv_fs_event_start(m_fsEvent, xmrig::Watcher::onFsEvent, m_path, 0); +} diff --git a/src/base/io/Watcher.h b/src/base/io/Watcher.h new file mode 100644 index 000000000..4fec4c687 --- /dev/null +++ b/src/base/io/Watcher.h @@ -0,0 +1,67 @@ +/* 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_WATCHER_H +#define XMRIG_WATCHER_H + + +#include "base/tools/String.h" + + +typedef struct uv_fs_event_s uv_fs_event_t; +typedef struct uv_timer_s uv_timer_t; + + +namespace xmrig { + + +class IWatcherListener; + + +class Watcher +{ +public: + Watcher(const String &path, IWatcherListener *listener); + ~Watcher(); + +private: + constexpr static int kDelay = 500; + + static void onFsEvent(uv_fs_event_t *handle, const char *filename, int events, int status); + static void onTimer(uv_timer_t *handle); + + void queueUpdate(); + void reload(); + void start(); + + IWatcherListener *m_listener; + String m_path; + uv_fs_event_t *m_fsEvent; + uv_timer_t *m_timer; +}; + + +} /* namespace xmrig */ + +#endif /* XMRIG_WATCHER_H */ diff --git a/src/base/kernel/interfaces/IConfigListener.h b/src/base/kernel/interfaces/IConfigListener.h new file mode 100644 index 000000000..a6fa835f2 --- /dev/null +++ b/src/base/kernel/interfaces/IConfigListener.h @@ -0,0 +1,47 @@ +/* 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_ICONFIGLISTENER_H +#define XMRIG_ICONFIGLISTENER_H + + +namespace xmrig { + + +class IConfig; + + +class IConfigListener +{ +public: + virtual ~IConfigListener() = default; + + virtual void onNewConfig(IConfig *config) = 0; +}; + + +} /* namespace xmrig */ + + +#endif // XMRIG_ICONFIGLISTENER_H diff --git a/src/common/interfaces/IWatcherListener.h b/src/base/kernel/interfaces/IWatcherListener.h similarity index 77% rename from src/common/interfaces/IWatcherListener.h rename to src/base/kernel/interfaces/IWatcherListener.h index bfafb9a01..a62b4b533 100644 --- a/src/common/interfaces/IWatcherListener.h +++ b/src/base/kernel/interfaces/IWatcherListener.h @@ -5,7 +5,8 @@ * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee * Copyright 2017-2018 XMR-Stak , - * Copyright 2016-2018 XMRig , + * 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 @@ -21,26 +22,26 @@ * along with this program. If not, see . */ -#ifndef __IWATCHERLISTENER_H__ -#define __IWATCHERLISTENER_H__ +#ifndef XMRIG_IWATCHERLISTENER_H +#define XMRIG_IWATCHERLISTENER_H namespace xmrig { -class IConfig; +class String; class IWatcherListener { public: - virtual ~IWatcherListener() {} + virtual ~IWatcherListener() = default; - virtual void onNewConfig(IConfig *config) = 0; + virtual void onFileChanged(const String &fileName) = 0; }; } /* namespace xmrig */ -#endif // __IWATCHERLISTENER_H__ +#endif // XMRIG_IWATCHERLISTENER_H diff --git a/src/base/tools/Handle.cpp b/src/base/tools/Handle.cpp new file mode 100644 index 000000000..d486ab39f --- /dev/null +++ b/src/base/tools/Handle.cpp @@ -0,0 +1,79 @@ +/* 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 . + */ + + +#include + + +#include "base/tools/Handle.h" + + +void xmrig::Handle::close(uv_fs_event_t *handle) +{ + if (handle) { + uv_fs_event_stop(handle); + close(reinterpret_cast(handle)); + } +} + + +void xmrig::Handle::close(uv_getaddrinfo_t *handle) +{ + if (handle) { + uv_cancel(reinterpret_cast(handle)); + close(reinterpret_cast(handle)); + } +} + + +void xmrig::Handle::close(uv_handle_t *handle) +{ + uv_close(handle, [](uv_handle_t *handle) { delete handle; }); +} + + +void xmrig::Handle::close(uv_signal_t *handle) +{ + if (handle) { + uv_signal_stop(handle); + close(reinterpret_cast(handle)); + } +} + + +void xmrig::Handle::close(uv_tcp_t *handle) +{ + if (handle) { + close(reinterpret_cast(handle)); + } +} + + +void xmrig::Handle::close(uv_timer_s *handle) +{ + if (handle) { + uv_timer_stop(handle); + close(reinterpret_cast(handle)); + } +} diff --git a/src/base/tools/Handle.h b/src/base/tools/Handle.h new file mode 100644 index 000000000..547c92026 --- /dev/null +++ b/src/base/tools/Handle.h @@ -0,0 +1,55 @@ +/* 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_HANDLE_H +#define XMRIG_HANDLE_H + + +typedef struct uv_fs_event_s uv_fs_event_t; +typedef struct uv_getaddrinfo_s uv_getaddrinfo_t; +typedef struct uv_handle_s uv_handle_t; +typedef struct uv_signal_s uv_signal_t; +typedef struct uv_tcp_s uv_tcp_t; +typedef struct uv_timer_s uv_timer_t; + + +namespace xmrig { + + +class Handle +{ +public: + static void close(uv_fs_event_t *handle); + static void close(uv_getaddrinfo_t *handle); + static void close(uv_handle_t *handle); + static void close(uv_signal_t *handle); + static void close(uv_tcp_t *handle); + static void close(uv_timer_t *handle); +}; + + +} /* namespace xmrig */ + + +#endif /* XMRIG_HANDLE_H */ diff --git a/src/common/config/CommonConfig.h b/src/common/config/CommonConfig.h index 40124b370..619f4b03a 100644 --- a/src/common/config/CommonConfig.h +++ b/src/common/config/CommonConfig.h @@ -65,7 +65,7 @@ public: inline bool isWatch() const override { return m_watch && !m_fileName.isNull(); } inline const Algorithm &algorithm() const override { return m_algorithm; } - inline const char *fileName() const override { return m_fileName.data(); } + inline const String &fileName() const override { return m_fileName; } bool save() override; diff --git a/src/common/config/ConfigLoader.cpp b/src/common/config/ConfigLoader.cpp index 6ce918d69..c60953a12 100644 --- a/src/common/config/ConfigLoader.cpp +++ b/src/common/config/ConfigLoader.cpp @@ -39,23 +39,22 @@ #include "base/io/Json.h" +#include "base/kernel/interfaces/IConfigListener.h" #include "common/config/ConfigLoader.h" #include "common/config/ConfigWatcher.h" #include "common/interfaces/IConfig.h" -#include "common/interfaces/IWatcherListener.h" #include "common/net/Pool.h" #include "common/Platform.h" #include "core/ConfigCreator.h" #include "core/ConfigLoader_platform.h" #include "rapidjson/document.h" #include "rapidjson/error/en.h" -#include "rapidjson/filereadstream.h" bool xmrig::ConfigLoader::m_done = false; xmrig::ConfigWatcher *xmrig::ConfigLoader::m_watcher = nullptr; xmrig::IConfigCreator *xmrig::ConfigLoader::m_creator = nullptr; -xmrig::IWatcherListener *xmrig::ConfigLoader::m_listener = nullptr; +xmrig::IConfigListener *xmrig::ConfigLoader::m_listener = nullptr; #ifndef ARRAY_SIZE @@ -78,8 +77,9 @@ bool xmrig::ConfigLoader::loadFromFile(xmrig::IConfig *config, const char *fileN bool xmrig::ConfigLoader::loadFromJSON(xmrig::IConfig *config, const char *json) { - rapidjson::Document doc; - doc.Parse(json); + using namespace rapidjson; + Document doc; + doc.Parse(json); if (doc.HasParseError() || !doc.IsObject()) { return false; @@ -144,7 +144,7 @@ bool xmrig::ConfigLoader::reload(xmrig::IConfig *oldConfig, const char *json) } -xmrig::IConfig *xmrig::ConfigLoader::load(int argc, char **argv, IConfigCreator *creator, IWatcherListener *listener) +xmrig::IConfig *xmrig::ConfigLoader::load(int argc, char **argv, IConfigCreator *creator, IConfigListener *listener) { m_creator = creator; m_listener = listener; diff --git a/src/common/config/ConfigLoader.h b/src/common/config/ConfigLoader.h index b0bd67eb4..13ac357bf 100644 --- a/src/common/config/ConfigLoader.h +++ b/src/common/config/ConfigLoader.h @@ -40,7 +40,7 @@ namespace xmrig { class ConfigWatcher; class IConfigCreator; -class IWatcherListener; +class IConfigListener; class IConfig; @@ -51,7 +51,7 @@ public: static bool loadFromJSON(IConfig *config, const char *json); static bool loadFromJSON(IConfig *config, const rapidjson::Document &doc); static bool reload(IConfig *oldConfig, const char *json); - static IConfig *load(int argc, char **argv, IConfigCreator *creator, IWatcherListener *listener); + static IConfig *load(int argc, char **argv, IConfigCreator *creator, IConfigListener *listener); static void release(); static inline bool isDone() { return m_done; } @@ -66,7 +66,7 @@ private: static bool m_done; static ConfigWatcher *m_watcher; static IConfigCreator *m_creator; - static IWatcherListener *m_listener; + static IConfigListener *m_listener; }; diff --git a/src/common/config/ConfigWatcher.cpp b/src/common/config/ConfigWatcher.cpp index 14107b62c..1e35bc9b7 100644 --- a/src/common/config/ConfigWatcher.cpp +++ b/src/common/config/ConfigWatcher.cpp @@ -5,7 +5,8 @@ * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee * Copyright 2017-2018 XMR-Stak , - * Copyright 2016-2018 XMRig , + * 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 @@ -22,66 +23,35 @@ */ -#include - - +#include "base/io/Watcher.h" +#include "base/kernel/interfaces/IConfigListener.h" #include "common/config/ConfigLoader.h" #include "common/config/ConfigWatcher.h" -#include "common/interfaces/IWatcherListener.h" #include "common/log/Log.h" #include "core/ConfigCreator.h" -xmrig::ConfigWatcher::ConfigWatcher(const char *path, IConfigCreator *creator, IWatcherListener *listener) : +xmrig::ConfigWatcher::ConfigWatcher(const String &path, IConfigCreator *creator, IConfigListener *listener) : m_creator(creator), - m_listener(listener), - m_path(path) + m_listener(listener) { - uv_fs_event_init(uv_default_loop(), &m_fsEvent); - uv_timer_init(uv_default_loop(), &m_timer); - - m_fsEvent.data = m_timer.data = this; - - start(); + m_watcher = new Watcher(path, this); } xmrig::ConfigWatcher::~ConfigWatcher() { - uv_timer_stop(&m_timer); - uv_fs_event_stop(&m_fsEvent); + delete m_watcher; } -void xmrig::ConfigWatcher::onTimer(uv_timer_t* handle) + +void xmrig::ConfigWatcher::onFileChanged(const String &fileName) { - static_cast(handle->data)->reload(); -} - - -void xmrig::ConfigWatcher::onFsEvent(uv_fs_event_t* handle, const char *filename, int events, int status) -{ - if (!filename) { - return; - } - - static_cast(handle->data)->queueUpdate(); -} - - -void xmrig::ConfigWatcher::queueUpdate() -{ - uv_timer_stop(&m_timer); - uv_timer_start(&m_timer, xmrig::ConfigWatcher::onTimer, kDelay, 0); -} - - -void xmrig::ConfigWatcher::reload() -{ - LOG_WARN("\"%s\" was changed, reloading configuration", m_path.data()); + LOG_WARN("\"%s\" was changed, reloading configuration", fileName.data()); IConfig *config = m_creator->create(); - ConfigLoader::loadFromFile(config, m_path.data()); + ConfigLoader::loadFromFile(config, fileName); if (!config->finalize()) { LOG_ERR("reloading failed"); @@ -91,15 +61,4 @@ void xmrig::ConfigWatcher::reload() } m_listener->onNewConfig(config); - -# ifndef _WIN32 - uv_fs_event_stop(&m_fsEvent); - start(); -# endif -} - - -void xmrig::ConfigWatcher::start() -{ - uv_fs_event_start(&m_fsEvent, xmrig::ConfigWatcher::onFsEvent, m_path.data(), 0); } diff --git a/src/common/config/ConfigWatcher.h b/src/common/config/ConfigWatcher.h index 7f38b45a8..c2c3ee29b 100644 --- a/src/common/config/ConfigWatcher.h +++ b/src/common/config/ConfigWatcher.h @@ -5,7 +5,8 @@ * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee * Copyright 2017-2018 XMR-Stak , - * Copyright 2016-2018 XMRig , + * 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 @@ -21,15 +22,12 @@ * along with this program. If not, see . */ -#ifndef __CONFIGWATCHER_H__ -#define __CONFIGWATCHER_H__ +#ifndef XMRIG_CONFIGWATCHER_H +#define XMRIG_CONFIGWATCHER_H -#include -#include - - -#include "common/utils/c_str.h" +#include "base/kernel/interfaces/IWatcherListener.h" +#include "base/tools/String.h" #include "rapidjson/fwd.h" @@ -40,29 +38,23 @@ namespace xmrig { class IConfigCreator; -class IWatcherListener; +class IConfigListener; +class Watcher; -class ConfigWatcher +class ConfigWatcher : public IWatcherListener { public: - ConfigWatcher(const char *path, IConfigCreator *creator, IWatcherListener *listener); - ~ConfigWatcher(); + ConfigWatcher(const String &path, IConfigCreator *creator, IConfigListener *listener); + ~ConfigWatcher() override; + +protected: + void onFileChanged(const String &fileName) override; private: - constexpr static int kDelay = 500; - - static void onFsEvent(uv_fs_event_t* handle, const char *filename, int events, int status); - static void onTimer(uv_timer_t* handle); - void queueUpdate(); - void reload(); - void start(); - IConfigCreator *m_creator; - IWatcherListener *m_listener; - uv_fs_event_t m_fsEvent; - uv_timer_t m_timer; - xmrig::c_str m_path; + IConfigListener *m_listener; + Watcher *m_watcher; }; diff --git a/src/common/interfaces/IConfig.h b/src/common/interfaces/IConfig.h index 48809fa17..d5f67c492 100644 --- a/src/common/interfaces/IConfig.h +++ b/src/common/interfaces/IConfig.h @@ -33,6 +33,9 @@ namespace xmrig { +class String; + + class IConfig { public: @@ -136,7 +139,7 @@ public: virtual bool parseUint64(int key, uint64_t arg) = 0; virtual bool save() = 0; virtual const Algorithm &algorithm() const = 0; - virtual const char *fileName() const = 0; + virtual const String &fileName() const = 0; virtual void getJSON(rapidjson::Document &doc) const = 0; virtual void parseJSON(const rapidjson::Document &doc) = 0; virtual void setFileName(const char *fileName) = 0; diff --git a/src/common/interfaces/IConfigCreator.h b/src/common/interfaces/IConfigCreator.h index 597a6b742..c2e0e62ea 100644 --- a/src/common/interfaces/IConfigCreator.h +++ b/src/common/interfaces/IConfigCreator.h @@ -4,7 +4,9 @@ * Copyright 2014 Lucas Jones * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee - * Copyright 2016-2018 XMRig + * 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 @@ -20,8 +22,8 @@ * along with this program. If not, see . */ -#ifndef __ICONFIGCREATOR_H__ -#define __ICONFIGCREATOR_H__ +#ifndef XMRIG_ICONFIGCREATOR_H +#define XMRIG_ICONFIGCREATOR_H namespace xmrig { @@ -33,7 +35,7 @@ class IConfig; class IConfigCreator { public: - virtual ~IConfigCreator() {} + virtual ~IConfigCreator() = default; virtual IConfig *create() const = 0; }; @@ -42,4 +44,4 @@ public: } /* namespace xmrig */ -#endif // __ICONFIGCREATOR_H__ +#endif // XMRIG_ICONFIGCREATOR_H diff --git a/src/core/Config.cpp b/src/core/Config.cpp index e91a9f2b4..1decb9410 100644 --- a/src/core/Config.cpp +++ b/src/core/Config.cpp @@ -139,7 +139,7 @@ void xmrig::Config::getJSON(rapidjson::Document &doc) const } -xmrig::Config *xmrig::Config::load(int argc, char **argv, IWatcherListener *listener) +xmrig::Config *xmrig::Config::load(int argc, char **argv, IConfigListener *listener) { return static_cast(ConfigLoader::load(argc, argv, new ConfigCreator(), listener)); } diff --git a/src/core/Config.h b/src/core/Config.h index eb33ee145..5b40a47e4 100644 --- a/src/core/Config.h +++ b/src/core/Config.h @@ -44,7 +44,7 @@ namespace xmrig { class ConfigLoader; class IThread; -class IWatcherListener; +class IConfigListener; /** @@ -85,7 +85,7 @@ public: inline int64_t affinity() const { return m_threads.mask; } inline ThreadsMode threadsMode() const { return m_threads.mode; } - static Config *load(int argc, char **argv, IWatcherListener *listener); + static Config *load(int argc, char **argv, IConfigListener *listener); protected: bool finalize() override; diff --git a/src/core/ConfigLoader_platform.h b/src/core/ConfigLoader_platform.h index 807d80e25..ceaf7a3fd 100644 --- a/src/core/ConfigLoader_platform.h +++ b/src/core/ConfigLoader_platform.h @@ -5,8 +5,8 @@ * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee * Copyright 2017-2018 XMR-Stak , - * Copyright 2016-2018 XMRig , - * + * 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 @@ -122,6 +122,7 @@ static struct option const options[] = { { "max-cpu-usage", 1, nullptr, xmrig::IConfig::MaxCPUUsageKey }, { "nicehash", 0, nullptr, xmrig::IConfig::NicehashKey }, { "no-color", 0, nullptr, xmrig::IConfig::ColorKey }, + { "no-watch", 0, nullptr, xmrig::IConfig::WatchKey }, { "no-huge-pages", 0, nullptr, xmrig::IConfig::HugePagesKey }, { "variant", 1, nullptr, xmrig::IConfig::VariantKey }, { "pass", 1, nullptr, xmrig::IConfig::PasswordKey }, @@ -163,6 +164,7 @@ static struct option const config_options[] = { { "syslog", 0, nullptr, xmrig::IConfig::SyslogKey }, { "threads", 1, nullptr, xmrig::IConfig::ThreadsKey }, { "user-agent", 1, nullptr, xmrig::IConfig::UserAgentKey }, + { "watch", 0, nullptr, xmrig::IConfig::WatchKey }, { "hw-aes", 0, nullptr, xmrig::IConfig::HardwareAESKey }, { "asm", 1, nullptr, xmrig::IConfig::AssemblyKey }, { "autosave", 0, nullptr, xmrig::IConfig::AutoSaveKey }, diff --git a/src/core/Controller.cpp b/src/core/Controller.cpp index 7a9b8284a..b9c64ca1c 100644 --- a/src/core/Controller.cpp +++ b/src/core/Controller.cpp @@ -5,7 +5,8 @@ * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee * Copyright 2017-2018 XMR-Stak , - * Copyright 2016-2018 XMRig , + * 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 diff --git a/src/core/Controller.h b/src/core/Controller.h index abb11ecfb..199343734 100644 --- a/src/core/Controller.h +++ b/src/core/Controller.h @@ -5,7 +5,8 @@ * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee * Copyright 2017-2018 XMR-Stak , - * Copyright 2016-2018 XMRig , + * 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 @@ -25,7 +26,7 @@ #define XMRIG_CONTROLLER_H -#include "common/interfaces/IWatcherListener.h" +#include "base/kernel/interfaces/IConfigListener.h" class Network; @@ -40,11 +41,11 @@ class ControllerPrivate; class IControllerListener; -class Controller : public IWatcherListener +class Controller : public IConfigListener { public: Controller(); - ~Controller(); + ~Controller() override; bool isDone() const; bool isReady() const;