diff --git a/src/controller/controller.cpp b/src/controller/controller.cpp index 1e5e2062..5e59e912 100644 --- a/src/controller/controller.cpp +++ b/src/controller/controller.cpp @@ -301,16 +301,18 @@ int main(int argc, char ** argv){ //start main loop Controller::conf.serveThreadedSocket(Controller::handleAPIConnection); //print shutdown reason + std::string shutdown_reason; + if (!Controller::conf.is_active){ + shutdown_reason = "user request (received shutdown signal)"; + }else{ + shutdown_reason = "socket problem (API port closed)"; + } /*LTS-START*/ if (Controller::restarting){ - Controller::Log("CONF", "Controller restarting for update"); + shutdown_reason = "update (on request)"; } /*LTS-END*/ - if (!Controller::conf.is_active){ - Controller::Log("CONF", "Controller shutting down because of user request (received shutdown signal)"); - }else{ - Controller::Log("CONF", "Controller shutting down because of socket problem (API port closed)"); - } + Controller::Log("CONF", "Controller shutting down because of "+shutdown_reason); Controller::conf.is_active = false; //join all joinable threads statsThread.join(); diff --git a/src/controller/controller_storage.cpp b/src/controller/controller_storage.cpp index 68a0770f..fab608cb 100644 --- a/src/controller/controller_storage.cpp +++ b/src/controller/controller_storage.cpp @@ -76,10 +76,24 @@ namespace Controller { /// Writes the current config to shared memory to be used in other processes void writeConfig(){ - JSON::Value writeConf; - writeConf["config"] = Storage["config"]; - writeConf["streams"] = Storage["streams"]; - writeConf["capabilities"] = capabilities; + static JSON::Value writeConf; + bool changed = false; + if (writeConf["config"] != Storage["config"]){ + writeConf["config"] = Storage["config"]; + VERYHIGH_MSG("Saving new config because of edit in server config structure"); + changed = true; + } + if (writeConf["streams"] != Storage["streams"]){ + writeConf["streams"] = Storage["streams"]; + VERYHIGH_MSG("Saving new config because of edit in streams"); + changed = true; + } + if (writeConf["capabilities"] != capabilities){ + writeConf["capabilities"] = capabilities; + VERYHIGH_MSG("Saving new config because of edit in capabilities"); + changed = true; + } + if (!changed){return;}//cancel further processing if no changes static IPC::sharedPage mistConfOut("!mistConfig", DEFAULT_CONF_PAGE_SIZE, true); IPC::semaphore configLock("!mistConfLock", O_CREAT | O_RDWR, ACCESSPERMS, 1); diff --git a/src/output/output.cpp b/src/output/output.cpp index 0861dd72..bc615502 100644 --- a/src/output/output.cpp +++ b/src/output/output.cpp @@ -96,6 +96,9 @@ namespace Mist { /// thus causing the process to exit cleanly. void Output::onFail(){ isInitialized = false; + wantRequest = true; + parseData= false; + streamName.clear(); myConn.close(); }