mirror of https://github.com/Icinga/icinga2.git
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);
|
||||
}
|
||||
|
||||
void icinga::AssertNoCircularReferences(const Value& value)
|
||||
{
|
||||
SerializeStack stack;
|
||||
SerializeInternal(value, FAConfig, stack, true);
|
||||
}
|
||||
|
||||
Value icinga::Serialize(const Value& value, int attributeTypes)
|
||||
{
|
||||
SerializeStack stack;
|
||||
|
|
|
@ -24,6 +24,7 @@ private:
|
|||
std::vector<String> m_Path;
|
||||
};
|
||||
|
||||
void AssertNoCircularReferences(const Value& value);
|
||||
Value Serialize(const Value& value, 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);
|
||||
|
|
|
@ -281,7 +281,11 @@ ConfigObject::Ptr ConfigItem::Commit(bool discard)
|
|||
Value serializedObject;
|
||||
|
||||
try {
|
||||
if (ConfigCompilerContext::GetInstance()->IsOpen()) {
|
||||
serializedObject = Serialize(dobj, FAConfig);
|
||||
} else {
|
||||
AssertNoCircularReferences(dobj);
|
||||
}
|
||||
} catch (const CircularReferenceError& ex) {
|
||||
BOOST_THROW_EXCEPTION(ValidationError(dobj, ex.GetPath(), "Circular references are not allowed"));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue