Merge pull request #8594 from Icinga/feature/remove-upq-from-activate-items

Remove upq from ConfigItem::ActivateItems
This commit is contained in:
Alexander Aleksandrovič Klimov 2021-01-15 12:09:57 +01:00 committed by GitHub
commit 986bedd9a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 15 deletions

View File

@ -275,11 +275,8 @@ int RunWorker(const std::vector<std::string>& configs, bool closeConsoleLog = fa
return EXIT_FAILURE;
}
WorkQueue upq(25000, Configuration::Concurrency);
upq.SetName("DaemonCommand::Run");
// activate config only after daemonization: it starts threads and that is not compatible with fork()
if (!ConfigItem::ActivateItems(upq, newItems, false, false, true)) {
if (!ConfigItem::ActivateItems(newItems, false, false, true)) {
Log(LogCritical, "cli", "Error activating configuration.");
return EXIT_FAILURE;
}

View File

@ -624,7 +624,7 @@ bool ConfigItem::CommitItems(const ActivationContext::Ptr& context, WorkQueue& u
return true;
}
bool ConfigItem::ActivateItems(WorkQueue& upq, const std::vector<ConfigItem::Ptr>& newItems, bool runtimeCreated,
bool ConfigItem::ActivateItems(const std::vector<ConfigItem::Ptr>& newItems, bool runtimeCreated,
bool silent, bool withModAttrs, const Value& cookie)
{
static boost::mutex mtx;
@ -697,13 +697,6 @@ bool ConfigItem::ActivateItems(WorkQueue& upq, const std::vector<ConfigItem::Ptr
}
}
upq.Join();
if (upq.HasExceptions()) {
upq.ReportExceptions("ConfigItem");
return false;
}
#ifdef I2_DEBUG
for (const ConfigItem::Ptr& item : newItems) {
ConfigObject::Ptr object = item->m_Object;
@ -738,7 +731,7 @@ bool ConfigItem::RunWithActivationContext(const Function::Ptr& function)
if (!CommitItems(scope.GetContext(), upq, newItems, true))
return false;
if (!ActivateItems(upq, newItems, false, true))
if (!ActivateItems(newItems, false, true))
return false;
return true;

View File

@ -53,7 +53,7 @@ public:
const String& name);
static bool CommitItems(const ActivationContext::Ptr& context, WorkQueue& upq, std::vector<ConfigItem::Ptr>& newItems, bool silent = false);
static bool ActivateItems(WorkQueue& upq, const std::vector<ConfigItem::Ptr>& newItems, bool runtimeCreated = false,
static bool ActivateItems(const std::vector<ConfigItem::Ptr>& newItems, bool runtimeCreated = false,
bool silent = false, bool withModAttrs = false, const Value& cookie = Empty);
static bool RunWithActivationContext(const Function::Ptr& function);

View File

@ -224,7 +224,7 @@ bool ConfigObjectUtility::CreateObject(const Type::Ptr& type, const String& full
* uq, items, runtimeCreated, silent, withModAttrs, cookie
* IMPORTANT: Forward the cookie aka origin in order to prevent sync loops in the same zone!
*/
if (!ConfigItem::ActivateItems(upq, newItems, true, true, false, cookie)) {
if (!ConfigItem::ActivateItems(newItems, true, true, false, cookie)) {
if (errors) {
Log(LogNotice, "ConfigObjectUtility")
<< "Failed to activate config object '" << fullName << "'. Aborting and removing config path '" << path << "'.";