diff --git a/src/controller/controller.cpp b/src/controller/controller.cpp index 2205e482..2fb7796e 100644 --- a/src/controller/controller.cpp +++ b/src/controller/controller.cpp @@ -274,6 +274,7 @@ int main(int argc, char ** argv){ //write config if ( !Controller::WriteFile(Controller::conf.getString("configFile"), Controller::Storage.toString())){ std::cerr << "Error writing config " << Controller::conf.getString("configFile") << std::endl; + tthread::lock_guard guard(Controller::logMutex); Controller::Storage.removeMember("log"); for (JSON::ObjIter it = Controller::Storage["streams"].ObjBegin(); it != Controller::Storage["streams"].ObjEnd(); it++){ it->second.removeMember("meta"); diff --git a/src/controller/controller_api.cpp b/src/controller/controller_api.cpp index 402db1ce..577048e3 100644 --- a/src/controller/controller_api.cpp +++ b/src/controller/controller_api.cpp @@ -318,10 +318,13 @@ int Controller::handleAPIConnection(Socket::Connection & conn){ /// ~~~~~~~~~~~~~~~ /// It's possible to clear the stored logs by sending an empty `"clearstatlogs"` request. /// - Response["log"] = Controller::Storage["log"]; - //clear log and statistics if requested - if (Request.isMember("clearstatlogs")){ - Controller::Storage["log"].null(); + { + tthread::lock_guard guard(logMutex); + Response["log"] = Controller::Storage["log"]; + //clear log if requested + if (Request.isMember("clearstatlogs")){ + Controller::Storage["log"].null(); + } } if (Request.isMember("clients")){ if (Request["clients"].isArray()){