mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-27 07:34:15 +02:00
parent
dfa2ac450c
commit
00712f1902
@ -169,9 +169,17 @@ static void PersistModAttrHelper(std::ofstream& fp, ConfigObject::Ptr& previousO
|
|||||||
void IcingaApplication::DumpProgramState(void)
|
void IcingaApplication::DumpProgramState(void)
|
||||||
{
|
{
|
||||||
ConfigObject::DumpObjects(GetStatePath());
|
ConfigObject::DumpObjects(GetStatePath());
|
||||||
|
DumpModifiedAttributes();
|
||||||
|
}
|
||||||
|
|
||||||
|
void IcingaApplication::DumpModifiedAttributes(void)
|
||||||
|
{
|
||||||
String path = GetModAttrPath();
|
String path = GetModAttrPath();
|
||||||
std::ofstream fp(path.CStr(), std::ofstream::out | std::ostream::trunc);
|
String pathtmp = path + ".tmp";
|
||||||
|
|
||||||
|
std::ofstream fp;
|
||||||
|
fp.open(pathtmp.CStr(), std::ofstream::out | std::ofstream::trunc);
|
||||||
|
|
||||||
ConfigObject::Ptr previousObject;
|
ConfigObject::Ptr previousObject;
|
||||||
ConfigObject::DumpModifiedAttributes(boost::bind(&PersistModAttrHelper, boost::ref(fp), boost::ref(previousObject), _1, _2, _3));
|
ConfigObject::DumpModifiedAttributes(boost::bind(&PersistModAttrHelper, boost::ref(fp), boost::ref(previousObject), _1, _2, _3));
|
||||||
|
|
||||||
@ -180,6 +188,19 @@ void IcingaApplication::DumpProgramState(void)
|
|||||||
ConfigWriter::EmitValue(fp, 0, previousObject->GetVersion());
|
ConfigWriter::EmitValue(fp, 0, previousObject->GetVersion());
|
||||||
ConfigWriter::EmitRaw(fp, "\n}\n");
|
ConfigWriter::EmitRaw(fp, "\n}\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fp.close();
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
_unlink(path.CStr());
|
||||||
|
#endif /* _WIN32 */
|
||||||
|
|
||||||
|
if (rename(pathtmp.CStr(), path.CStr()) < 0) {
|
||||||
|
BOOST_THROW_EXCEPTION(posix_error()
|
||||||
|
<< boost::errinfo_api_function("rename")
|
||||||
|
<< boost::errinfo_errno(errno)
|
||||||
|
<< boost::errinfo_file_name(pathtmp));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IcingaApplication::Ptr IcingaApplication::GetInstance(void)
|
IcingaApplication::Ptr IcingaApplication::GetInstance(void)
|
||||||
|
@ -56,6 +56,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void DumpProgramState(void);
|
void DumpProgramState(void);
|
||||||
|
void DumpModifiedAttributes(void);
|
||||||
|
|
||||||
virtual void OnShutdown(void) override;
|
virtual void OnShutdown(void) override;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user