mirror of https://github.com/Icinga/icinga2.git
Make sure all objects are set to 'active' before calling the Start() method
fixes #5224
This commit is contained in:
parent
2932651b64
commit
f9f3358d09
|
@ -374,6 +374,14 @@ void ConfigObject::Start(bool runtimeCreated)
|
|||
SetStartCalled(true);
|
||||
}
|
||||
|
||||
void ConfigObject::PreActivate(void)
|
||||
{
|
||||
CONTEXT("Setting 'active' to true for object '" + GetName() + "' of type '" + GetReflectionType()->GetName() + "'");
|
||||
|
||||
ASSERT(!IsActive());
|
||||
SetActive(true, true);
|
||||
}
|
||||
|
||||
void ConfigObject::Activate(bool runtimeCreated)
|
||||
{
|
||||
CONTEXT("Activating object '" + GetName() + "' of type '" + GetReflectionType()->GetName() + "'");
|
||||
|
@ -384,8 +392,6 @@ void ConfigObject::Activate(bool runtimeCreated)
|
|||
Start(runtimeCreated);
|
||||
|
||||
ASSERT(GetStartCalled());
|
||||
ASSERT(!IsActive());
|
||||
SetActive(true, true);
|
||||
|
||||
if (GetHAMode() == HARunEverywhere)
|
||||
SetAuthority(true);
|
||||
|
|
|
@ -60,6 +60,7 @@ public:
|
|||
void Register(void);
|
||||
void Unregister(void);
|
||||
|
||||
void PreActivate(void);
|
||||
void Activate(bool runtimeCreated = false);
|
||||
void Deactivate(bool runtimeRemoved = false);
|
||||
void SetAuthority(bool authority);
|
||||
|
|
|
@ -597,9 +597,6 @@ bool ConfigItem::ActivateItems(WorkQueue& upq, const std::vector<ConfigItem::Ptr
|
|||
}
|
||||
}
|
||||
|
||||
if (!silent)
|
||||
Log(LogInformation, "ConfigItem", "Triggering Start signal for config items");
|
||||
|
||||
for (const ConfigItem::Ptr& item : newItems) {
|
||||
if (!item->m_Object)
|
||||
continue;
|
||||
|
@ -609,6 +606,29 @@ bool ConfigItem::ActivateItems(WorkQueue& upq, const std::vector<ConfigItem::Ptr
|
|||
if (object->IsActive())
|
||||
continue;
|
||||
|
||||
#ifdef I2_DEBUG
|
||||
Log(LogDebug, "ConfigItem")
|
||||
<< "Setting 'active' to true for object '" << object->GetName() << "' of type '" << object->GetReflectionType()->GetName() << "'";
|
||||
#endif /* I2_DEBUG */
|
||||
upq.Enqueue(boost::bind(&ConfigObject::PreActivate, object));
|
||||
}
|
||||
|
||||
upq.Join();
|
||||
|
||||
if (upq.HasExceptions()) {
|
||||
upq.ReportExceptions("ConfigItem");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!silent)
|
||||
Log(LogInformation, "ConfigItem", "Triggering Start signal for config items");
|
||||
|
||||
for (const ConfigItem::Ptr& item : newItems) {
|
||||
if (!item->m_Object)
|
||||
continue;
|
||||
|
||||
ConfigObject::Ptr object = item->m_Object;
|
||||
|
||||
#ifdef I2_DEBUG
|
||||
Log(LogDebug, "ConfigItem")
|
||||
<< "Activating object '" << object->GetName() << "' of type '" << object->GetReflectionType()->GetName() << "'";
|
||||
|
|
Loading…
Reference in New Issue