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
|
||||
if ( !Controller::WriteFile(Controller::conf.getString("configFile"), Controller::Storage.toString())){
|
||||
std::cerr << "Error writing config " << Controller::conf.getString("configFile") << std::endl;
|
||||
tthread::lock_guard<tthread::mutex> 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");
|
||||
|
|
|
@ -318,11 +318,14 @@ int Controller::handleAPIConnection(Socket::Connection & conn){
|
|||
/// ~~~~~~~~~~~~~~~
|
||||
/// It's possible to clear the stored logs by sending an empty `"clearstatlogs"` request.
|
||||
///
|
||||
{
|
||||
tthread::lock_guard<tthread::mutex> guard(logMutex);
|
||||
Response["log"] = Controller::Storage["log"];
|
||||
//clear log and statistics if requested
|
||||
//clear log if requested
|
||||
if (Request.isMember("clearstatlogs")){
|
||||
Controller::Storage["log"].null();
|
||||
}
|
||||
}
|
||||
if (Request.isMember("clients")){
|
||||
if (Request["clients"].isArray()){
|
||||
for (unsigned int i = 0; i < Request["clients"].size(); ++i){
|
||||
|
|
Loading…
Add table
Reference in a new issue