From: Alexander A. Klimov Date: Thu, 6 Dec 2018 11:41:49 +0000 (+0100) Subject: Implement ScheduledDowntime::AllConfigIsLoaded() X-Git-Tag: v2.11.0-rc1~268^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bbcf469af1c584a92d028446c6ff1f558950cd97;p=icinga2 Implement ScheduledDowntime::AllConfigIsLoaded() refs #6542 --- diff --git a/lib/icinga/scheduleddowntime.cpp b/lib/icinga/scheduleddowntime.cpp index c092ca9f0..054f63628 100644 --- a/lib/icinga/scheduleddowntime.cpp +++ b/lib/icinga/scheduleddowntime.cpp @@ -80,6 +80,8 @@ void ScheduledDowntime::OnAllConfigLoaded() if (!GetCheckable()) BOOST_THROW_EXCEPTION(ScriptError("ScheduledDowntime '" + GetName() + "' references a host/service which doesn't exist.", GetDebugInfo())); + + m_AllConfigLoaded.store(true); } void ScheduledDowntime::Start(bool runtimeCreated) @@ -331,3 +333,10 @@ void ScheduledDowntime::ValidateChildOptions(const Lazy& lvalue, const Va BOOST_THROW_EXCEPTION(ValidationError(this, { "child_options" }, "Invalid child_options specified")); } } + +bool ScheduledDowntime::AllConfigIsLoaded() +{ + return m_AllConfigLoaded.load(); +} + +std::atomic ScheduledDowntime::m_AllConfigLoaded (false); diff --git a/lib/icinga/scheduleddowntime.hpp b/lib/icinga/scheduleddowntime.hpp index 158349291..4322999b7 100644 --- a/lib/icinga/scheduleddowntime.hpp +++ b/lib/icinga/scheduleddowntime.hpp @@ -23,6 +23,7 @@ #include "icinga/i2-icinga.hpp" #include "icinga/scheduleddowntime-ti.hpp" #include "icinga/checkable.hpp" +#include namespace icinga { @@ -47,6 +48,7 @@ public: static void EvaluateApplyRules(const intrusive_ptr& host); static void EvaluateApplyRules(const intrusive_ptr& service); + static bool AllConfigIsLoaded(); void ValidateRanges(const Lazy& lvalue, const ValidationUtils& utils) override; void ValidateChildOptions(const Lazy& lvalue, const ValidationUtils& utils) override; @@ -62,6 +64,8 @@ private: std::pair FindNextSegment(); void CreateNextDowntime(); + static std::atomic m_AllConfigLoaded; + static bool EvaluateApplyRuleInstance(const Checkable::Ptr& checkable, const String& name, ScriptFrame& frame, const ApplyRule& rule); static bool EvaluateApplyRule(const Checkable::Ptr& checkable, const ApplyRule& rule); };