Update objects.cache when config is changed

fixes #9098
This commit is contained in:
Gunnar Beutner 2015-09-22 11:56:27 +02:00
parent ad6c8eaf7e
commit c5fe42e0b0
2 changed files with 15 additions and 1 deletions

View File

@ -74,13 +74,15 @@ void StatusDataWriter::Start(void)
{
ObjectImpl<StatusDataWriter>::Start();
m_ObjectsCacheOutdated = true;
m_StatusTimer = new Timer();
m_StatusTimer->SetInterval(GetUpdateInterval());
m_StatusTimer->OnTimerExpired.connect(boost::bind(&StatusDataWriter::StatusTimerHandler, this));
m_StatusTimer->Start();
m_StatusTimer->Reschedule(0);
Utility::QueueAsyncCallback(boost::bind(&StatusDataWriter::UpdateObjectsCache, this));
ConfigObject::OnVersionChanged.connect(boost::bind(&StatusDataWriter::VersionChangedHandler, this));
}
void StatusDataWriter::DumpComments(std::ostream& fp, const Checkable::Ptr& checkable)
@ -784,6 +786,11 @@ void StatusDataWriter::UpdateObjectsCache(void)
*/
void StatusDataWriter::StatusTimerHandler(void)
{
if (m_ObjectsCacheOutdated) {
UpdateObjectsCache();
m_ObjectsCacheOutdated = false;
}
double start = Utility::GetTime();
String statuspath = GetStatusPath();
@ -859,3 +866,8 @@ void StatusDataWriter::StatusTimerHandler(void)
Log(LogNotice, "StatusDataWriter")
<< "Writing status.dat file took " << Utility::FormatDuration(Utility::GetTime() - start);
}
void StatusDataWriter::VersionChangedHandler(void)
{
m_ObjectsCacheOutdated = true;
}

View File

@ -51,6 +51,7 @@ protected:
private:
Timer::Ptr m_StatusTimer;
bool m_ObjectsCacheOutdated;
void DumpCommand(std::ostream& fp, const Command::Ptr& command);
void DumpTimePeriod(std::ostream& fp, const TimePeriod::Ptr& tp);
@ -99,6 +100,7 @@ private:
void UpdateObjectsCache(void);
void StatusTimerHandler(void);
void VersionChangedHandler(void);
};
}