Prevent config reload after initial save.
This commit is contained in:
parent
f4d2dec628
commit
14e7c82512
6 changed files with 31 additions and 13 deletions
|
@ -74,13 +74,7 @@ xmrig::CommonConfig::CommonConfig() :
|
||||||
m_colors(true),
|
m_colors(true),
|
||||||
m_dryRun(false),
|
m_dryRun(false),
|
||||||
m_syslog(false),
|
m_syslog(false),
|
||||||
|
|
||||||
# ifdef XMRIG_PROXY_PROJECT
|
|
||||||
m_watch(true),
|
m_watch(true),
|
||||||
# else
|
|
||||||
m_watch(false), // TODO: enable config file watch by default when this feature propertly handled and tested.
|
|
||||||
# endif
|
|
||||||
|
|
||||||
m_apiPort(0),
|
m_apiPort(0),
|
||||||
m_donateLevel(kDefaultDonateLevel),
|
m_donateLevel(kDefaultDonateLevel),
|
||||||
m_printTime(60),
|
m_printTime(60),
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <uv.h>
|
#include <uv.h>
|
||||||
|
@ -145,6 +146,19 @@ bool xmrig::ConfigLoader::reload(xmrig::IConfig *oldConfig, const char *json)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool xmrig::ConfigLoader::watch(IConfig *config)
|
||||||
|
{
|
||||||
|
if (!config->isWatch()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(m_watcher == nullptr);
|
||||||
|
|
||||||
|
m_watcher = new xmrig::ConfigWatcher(config->fileName(), m_creator, m_listener);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
xmrig::IConfig *xmrig::ConfigLoader::load(Process *process, IConfigCreator *creator, IConfigListener *listener)
|
xmrig::IConfig *xmrig::ConfigLoader::load(Process *process, IConfigCreator *creator, IConfigListener *listener)
|
||||||
{
|
{
|
||||||
m_creator = creator;
|
m_creator = creator;
|
||||||
|
@ -192,10 +206,6 @@ xmrig::IConfig *xmrig::ConfigLoader::load(Process *process, IConfigCreator *crea
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config->isWatch()) {
|
|
||||||
m_watcher = new xmrig::ConfigWatcher(config->fileName(), creator, listener);
|
|
||||||
}
|
|
||||||
|
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,7 @@ public:
|
||||||
static bool loadFromJSON(IConfig *config, const char *json);
|
static bool loadFromJSON(IConfig *config, const char *json);
|
||||||
static bool loadFromJSON(IConfig *config, const rapidjson::Document &doc);
|
static bool loadFromJSON(IConfig *config, const rapidjson::Document &doc);
|
||||||
static bool reload(IConfig *oldConfig, const char *json);
|
static bool reload(IConfig *oldConfig, const char *json);
|
||||||
|
static bool watch(IConfig *config);
|
||||||
static IConfig *load(Process *process, IConfigCreator *creator, IConfigListener *listener);
|
static IConfig *load(Process *process, IConfigCreator *creator, IConfigListener *listener);
|
||||||
static void release();
|
static void release();
|
||||||
|
|
||||||
|
|
|
@ -147,6 +147,20 @@ void xmrig::Controller::addListener(IControllerListener *listener)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void xmrig::Controller::save()
|
||||||
|
{
|
||||||
|
if (!config()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (d_ptr->config->isShouldSave()) {
|
||||||
|
d_ptr->config->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
ConfigLoader::watch(d_ptr->config);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void xmrig::Controller::onNewConfig(IConfig *config)
|
void xmrig::Controller::onNewConfig(IConfig *config)
|
||||||
{
|
{
|
||||||
Config *previousConfig = d_ptr->config;
|
Config *previousConfig = d_ptr->config;
|
||||||
|
|
|
@ -54,6 +54,7 @@ public:
|
||||||
int init();
|
int init();
|
||||||
Network *network() const;
|
Network *network() const;
|
||||||
void addListener(IControllerListener *listener);
|
void addListener(IControllerListener *listener);
|
||||||
|
void save();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void onNewConfig(IConfig *config) override;
|
void onNewConfig(IConfig *config) override;
|
||||||
|
|
|
@ -206,9 +206,7 @@ void Workers::start(xmrig::Controller *controller)
|
||||||
handle->start(Workers::onReady);
|
handle->start(Workers::onReady);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (controller->config()->isShouldSave()) {
|
controller->save();
|
||||||
controller->config()->save();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue