mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-26 23:24:09 +02:00
Cache locals of script frame used for group assign where eval
to avoid malloc(). This BREAKS assign where locals.x = 1.
This commit is contained in:
parent
805c78a7b9
commit
477d177b5a
@ -24,10 +24,20 @@ bool HostGroup::EvaluateObjectRule(const Host::Ptr& host, const ConfigItem::Ptr&
|
||||
|
||||
CONTEXT("Evaluating rule for group '" << groupName << "'");
|
||||
|
||||
ScriptFrame frame(true);
|
||||
if (group->GetScope())
|
||||
group->GetScope()->CopyTo(frame.Locals);
|
||||
frame.Locals->Set("host", host);
|
||||
ScriptFrame frame (false);
|
||||
|
||||
if (group->GetScope()) {
|
||||
frame.Locals = new Dictionary();
|
||||
|
||||
if (group->GetScope()) {
|
||||
group->GetScope()->CopyTo(frame.Locals);
|
||||
}
|
||||
|
||||
host->GetFrozenLocalsForApply()->CopyTo(frame.Locals);
|
||||
frame.Locals->Freeze();
|
||||
} else {
|
||||
frame.Locals = host->GetFrozenLocalsForApply();
|
||||
}
|
||||
|
||||
if (!group->GetFilter()->Evaluate(frame).GetValue().ToBool())
|
||||
return false;
|
||||
|
@ -24,13 +24,20 @@ bool ServiceGroup::EvaluateObjectRule(const Service::Ptr& service, const ConfigI
|
||||
|
||||
CONTEXT("Evaluating rule for group '" << groupName << "'");
|
||||
|
||||
Host::Ptr host = service->GetHost();
|
||||
ScriptFrame frame (false);
|
||||
|
||||
ScriptFrame frame(true);
|
||||
if (group->GetScope())
|
||||
group->GetScope()->CopyTo(frame.Locals);
|
||||
frame.Locals->Set("host", host);
|
||||
frame.Locals->Set("service", service);
|
||||
if (group->GetScope()) {
|
||||
frame.Locals = new Dictionary();
|
||||
|
||||
if (group->GetScope()) {
|
||||
group->GetScope()->CopyTo(frame.Locals);
|
||||
}
|
||||
|
||||
service->GetFrozenLocalsForApply()->CopyTo(frame.Locals);
|
||||
frame.Locals->Freeze();
|
||||
} else {
|
||||
frame.Locals = service->GetFrozenLocalsForApply();
|
||||
}
|
||||
|
||||
if (!group->GetFilter()->Evaluate(frame).GetValue().ToBool())
|
||||
return false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user