mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-23 21:55:03 +02:00
icinga2 daemon: w/o --dump-objects just check for circular refs
and don't malloc() anything.
This commit is contained in:
parent
e53ec2a50f
commit
7c481742f4
@ -291,6 +291,12 @@ static Value SerializeInternal(const Value& value, int attributeTypes, Serialize
|
|||||||
return SerializeObject(input, attributeTypes, stack, dryRun);
|
return SerializeObject(input, attributeTypes, stack, dryRun);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void icinga::AssertNoCircularReferences(const Value& value)
|
||||||
|
{
|
||||||
|
SerializeStack stack;
|
||||||
|
SerializeInternal(value, FAConfig, stack, true);
|
||||||
|
}
|
||||||
|
|
||||||
Value icinga::Serialize(const Value& value, int attributeTypes)
|
Value icinga::Serialize(const Value& value, int attributeTypes)
|
||||||
{
|
{
|
||||||
SerializeStack stack;
|
SerializeStack stack;
|
||||||
|
@ -24,6 +24,7 @@ private:
|
|||||||
std::vector<String> m_Path;
|
std::vector<String> m_Path;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void AssertNoCircularReferences(const Value& value);
|
||||||
Value Serialize(const Value& value, int attributeTypes = FAState);
|
Value Serialize(const Value& value, int attributeTypes = FAState);
|
||||||
Value Deserialize(const Value& value, bool safe_mode = false, int attributeTypes = FAState);
|
Value Deserialize(const Value& value, bool safe_mode = false, int attributeTypes = FAState);
|
||||||
Value Deserialize(const Object::Ptr& object, const Value& value, bool safe_mode = false, int attributeTypes = FAState);
|
Value Deserialize(const Object::Ptr& object, const Value& value, bool safe_mode = false, int attributeTypes = FAState);
|
||||||
|
@ -281,7 +281,11 @@ ConfigObject::Ptr ConfigItem::Commit(bool discard)
|
|||||||
Value serializedObject;
|
Value serializedObject;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
serializedObject = Serialize(dobj, FAConfig);
|
if (ConfigCompilerContext::GetInstance()->IsOpen()) {
|
||||||
|
serializedObject = Serialize(dobj, FAConfig);
|
||||||
|
} else {
|
||||||
|
AssertNoCircularReferences(dobj);
|
||||||
|
}
|
||||||
} catch (const CircularReferenceError& ex) {
|
} catch (const CircularReferenceError& ex) {
|
||||||
BOOST_THROW_EXCEPTION(ValidationError(dobj, ex.GetPath(), "Circular references are not allowed"));
|
BOOST_THROW_EXCEPTION(ValidationError(dobj, ex.GetPath(), "Circular references are not allowed"));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user