Skip to content

Commit

Permalink
Update objects.cache when config is changed
Browse files Browse the repository at this point in the history
fixes #9098
  • Loading branch information
gunnarbeutner committed Sep 22, 2015
1 parent ad6c8ea commit c5fe42e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/compat/statusdatawriter.cpp
Expand Up @@ -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)
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;
}
2 changes: 2 additions & 0 deletions lib/compat/statusdatawriter.hpp
Expand Up @@ -51,6 +51,7 @@ class StatusDataWriter : public ObjectImpl<StatusDataWriter>

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);
Expand Down Expand Up @@ -99,6 +100,7 @@ class StatusDataWriter : public ObjectImpl<StatusDataWriter>

void UpdateObjectsCache(void);
void StatusTimerHandler(void);
void VersionChangedHandler(void);
};

}
Expand Down

0 comments on commit c5fe42e

Please sign in to comment.