Semaphore fixes.

This commit is contained in:
Thulinma 2016-05-03 16:34:19 +02:00
parent 9498f87cc3
commit df16c815c2
5 changed files with 21 additions and 17 deletions

View file

@ -127,8 +127,9 @@ void statusMonitor(void * np){
changed = true;
}
configLock.post();
if (changed){
if (changed || Controller::configChanged){
Controller::writeConfig();
Controller::configChanged = false;
}
}
Util::wait(5000);//wait at least 5 seconds

View file

@ -572,7 +572,7 @@ int Controller::handleAPIConnection(Socket::Connection & conn){
Controller::fillActive(Request["stats_streams"], Response["stats_streams"]);
}
Controller::writeConfig();
Controller::configChanged = true;
}else{//unauthorized
Util::sleep(1000);//sleep a second to prevent bruteforcing

View file

@ -16,6 +16,8 @@ namespace Controller {
JSON::Value Storage; ///< Global storage of data.
tthread::mutex configMutex;
tthread::mutex logMutex;
bool configChanged = false;
///\brief Store and print a log message.
///\param kind The type of message.
///\param message The message to be logged.

View file

@ -8,6 +8,7 @@ namespace Controller {
extern JSON::Value Storage; ///< Global storage of data.
extern tthread::mutex logMutex;///< Mutex for log thread.
extern tthread::mutex configMutex;///< Mutex for server config access.
extern bool configChanged; ///< Bool that indicates config must be written to SHM.
/// Store and print a log message.
void Log(std::string kind, std::string message);

View file

@ -951,13 +951,12 @@ namespace Mist {
{
// @todo check if output is already running ?
if (recordingPid == -1
&& config != NULL
)
{
if (recordingPid == -1 && config != NULL){
configLock.post();
configLock.close();
INFO_MSG("The stream %s has a value specified for the recording. "
"We're goint to start an output and record into %s",
"We're going to start an output and record into %s",
config->getString("streamname").c_str(),
streamCfg.getMember("record").asString().c_str());
@ -968,6 +967,7 @@ namespace Mist {
// @todo discuss with Jaron. 2015.09.26, remove this comment when discussed.
}
INFO_MSG("We started an output for recording with PID: %d", recordingPid);
return true;
}
}
/* roxlu-end */