Merge pull request from Icinga/freeze-globals

Freeze globals namespace during config load
This commit is contained in:
Julian Brost 2023-03-31 10:51:26 +02:00 committed by GitHub
commit 82f9e4312d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -247,6 +247,11 @@ bool DaemonUtility::LoadConfigFiles(const std::vector<std::string>& configs,
return false;
}
// After evaluating the top-level statements of the config files (happening in ValidateConfigFiles() above),
// prevent further modification of the global scope. This allows for a faster execution of the following steps
// as Freeze() disables locking as it's not necessary on a read-only data structure anymore.
ScriptGlobal::GetGlobals()->Freeze();
WorkQueue upq(25000, Configuration::Concurrency);
upq.SetName("DaemonUtility::LoadConfigFiles");
bool result = ConfigItem::CommitItems(ascope.GetContext(), upq, newItems);