Fixed logging thread safety issues.
This commit is contained in:
parent
c33c62c6d4
commit
4e705195a8
2 changed files with 8 additions and 4 deletions
|
@ -274,6 +274,7 @@ int main(int argc, char ** argv){
|
||||||
//write config
|
//write config
|
||||||
if ( !Controller::WriteFile(Controller::conf.getString("configFile"), Controller::Storage.toString())){
|
if ( !Controller::WriteFile(Controller::conf.getString("configFile"), Controller::Storage.toString())){
|
||||||
std::cerr << "Error writing config " << Controller::conf.getString("configFile") << std::endl;
|
std::cerr << "Error writing config " << Controller::conf.getString("configFile") << std::endl;
|
||||||
|
tthread::lock_guard<tthread::mutex> guard(Controller::logMutex);
|
||||||
Controller::Storage.removeMember("log");
|
Controller::Storage.removeMember("log");
|
||||||
for (JSON::ObjIter it = Controller::Storage["streams"].ObjBegin(); it != Controller::Storage["streams"].ObjEnd(); it++){
|
for (JSON::ObjIter it = Controller::Storage["streams"].ObjBegin(); it != Controller::Storage["streams"].ObjEnd(); it++){
|
||||||
it->second.removeMember("meta");
|
it->second.removeMember("meta");
|
||||||
|
|
|
@ -318,10 +318,13 @@ int Controller::handleAPIConnection(Socket::Connection & conn){
|
||||||
/// ~~~~~~~~~~~~~~~
|
/// ~~~~~~~~~~~~~~~
|
||||||
/// It's possible to clear the stored logs by sending an empty `"clearstatlogs"` request.
|
/// 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
|
tthread::lock_guard<tthread::mutex> guard(logMutex);
|
||||||
if (Request.isMember("clearstatlogs")){
|
Response["log"] = Controller::Storage["log"];
|
||||||
Controller::Storage["log"].null();
|
//clear log if requested
|
||||||
|
if (Request.isMember("clearstatlogs")){
|
||||||
|
Controller::Storage["log"].null();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (Request.isMember("clients")){
|
if (Request.isMember("clients")){
|
||||||
if (Request["clients"].isArray()){
|
if (Request["clients"].isArray()){
|
||||||
|
|
Loading…
Add table
Reference in a new issue