mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-23 21:55:03 +02:00
Handle I/O errors while writing the Icinga state file more gracefully
fixes #12334
This commit is contained in:
parent
1aac54f4bb
commit
4c7e2994a7
@ -487,6 +487,7 @@ void ConfigObject::DumpObjects(const String& filename, int attributeTypes)
|
|||||||
|
|
||||||
std::fstream fp;
|
std::fstream fp;
|
||||||
String tempFilename = Utility::CreateTempFile(filename + ".XXXXXX", 0600, fp);
|
String tempFilename = Utility::CreateTempFile(filename + ".XXXXXX", 0600, fp);
|
||||||
|
fp.exceptions(std::ofstream::failbit | std::ofstream::badbit);
|
||||||
|
|
||||||
if (!fp)
|
if (!fp)
|
||||||
BOOST_THROW_EXCEPTION(std::runtime_error("Could not open '" + tempFilename + "' file"));
|
BOOST_THROW_EXCEPTION(std::runtime_error("Could not open '" + tempFilename + "' file"));
|
||||||
|
@ -176,6 +176,7 @@ void IcingaApplication::DumpModifiedAttributes(void)
|
|||||||
|
|
||||||
std::fstream fp;
|
std::fstream fp;
|
||||||
String tempFilename = Utility::CreateTempFile(path + ".XXXXXX", 0644, fp);
|
String tempFilename = Utility::CreateTempFile(path + ".XXXXXX", 0644, fp);
|
||||||
|
fp.exceptions(std::ofstream::failbit | std::ofstream::badbit);
|
||||||
|
|
||||||
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));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user