mirror of
https://github.com/Icinga/icinga2.git
synced 2025-04-07 20:25:08 +02:00
Merge pull request #8588 from Icinga/bugfix/concurrent-schedule-downtime-delete-host
Fix null pointer dereferences when deleting objects while scheduling downtimes
This commit is contained in:
commit
cbd0d6ea6e
@ -381,10 +381,9 @@ Dictionary::Ptr ApiActions::ScheduleDowntime(const ConfigObject::Ptr& object,
|
||||
}
|
||||
}
|
||||
|
||||
String downtimeName = Downtime::AddDowntime(checkable, author, comment, startTime, endTime,
|
||||
Downtime::Ptr downtime = Downtime::AddDowntime(checkable, author, comment, startTime, endTime,
|
||||
fixed, triggerName, duration);
|
||||
|
||||
Downtime::Ptr downtime = Downtime::GetByName(downtimeName);
|
||||
String downtimeName = downtime->GetName();
|
||||
|
||||
Dictionary::Ptr additional = new Dictionary({
|
||||
{ "name", downtimeName },
|
||||
@ -404,10 +403,9 @@ Dictionary::Ptr ApiActions::ScheduleDowntime(const ConfigObject::Ptr& object,
|
||||
Log(LogNotice, "ApiActions")
|
||||
<< "Creating downtime for service " << hostService->GetName() << " on host " << host->GetName();
|
||||
|
||||
String serviceDowntimeName = Downtime::AddDowntime(hostService, author, comment, startTime, endTime,
|
||||
Downtime::Ptr serviceDowntime = Downtime::AddDowntime(hostService, author, comment, startTime, endTime,
|
||||
fixed, triggerName, duration);
|
||||
|
||||
Downtime::Ptr serviceDowntime = Downtime::GetByName(serviceDowntimeName);
|
||||
String serviceDowntimeName = serviceDowntime->GetName();
|
||||
|
||||
serviceDowntimes.push_back(new Dictionary({
|
||||
{ "name", serviceDowntimeName },
|
||||
@ -435,14 +433,13 @@ Dictionary::Ptr ApiActions::ScheduleDowntime(const ConfigObject::Ptr& object,
|
||||
Log(LogNotice, "ApiActions")
|
||||
<< "Scheduling downtime for child object " << child->GetName();
|
||||
|
||||
String childDowntimeName = Downtime::AddDowntime(child, author, comment, startTime, endTime,
|
||||
Downtime::Ptr childDowntime = Downtime::AddDowntime(child, author, comment, startTime, endTime,
|
||||
fixed, triggerName, duration);
|
||||
String childDowntimeName = childDowntime->GetName();
|
||||
|
||||
Log(LogNotice, "ApiActions")
|
||||
<< "Add child downtime '" << childDowntimeName << "'.";
|
||||
|
||||
Downtime::Ptr childDowntime = Downtime::GetByName(childDowntimeName);
|
||||
|
||||
Dictionary::Ptr childAdditional = new Dictionary({
|
||||
{ "name", childDowntimeName },
|
||||
{ "legacy_id", childDowntime->GetLegacyId() }
|
||||
@ -460,10 +457,9 @@ Dictionary::Ptr ApiActions::ScheduleDowntime(const ConfigObject::Ptr& object,
|
||||
Log(LogNotice, "ApiActions")
|
||||
<< "Creating downtime for service " << hostService->GetName() << " on child host " << host->GetName();
|
||||
|
||||
String serviceDowntimeName = Downtime::AddDowntime(hostService, author, comment, startTime, endTime,
|
||||
Downtime::Ptr serviceDowntime = Downtime::AddDowntime(hostService, author, comment, startTime, endTime,
|
||||
fixed, triggerName, duration);
|
||||
|
||||
Downtime::Ptr serviceDowntime = Downtime::GetByName(serviceDowntimeName);
|
||||
String serviceDowntimeName = serviceDowntime->GetName();
|
||||
|
||||
childServiceDowntimes.push_back(new Dictionary({
|
||||
{ "name", serviceDowntimeName },
|
||||
|
@ -75,12 +75,10 @@ void Downtime::OnAllConfigLoaded()
|
||||
{
|
||||
ObjectImpl<Downtime>::OnAllConfigLoaded();
|
||||
|
||||
Host::Ptr host = Host::GetByName(GetHostName());
|
||||
|
||||
if (GetServiceName().IsEmpty())
|
||||
m_Checkable = host;
|
||||
m_Checkable = Host::GetByName(GetHostName());
|
||||
else
|
||||
m_Checkable = host->GetServiceByShortName(GetServiceName());
|
||||
m_Checkable = Service::GetByNamePair(GetHostName(), GetServiceName());
|
||||
|
||||
if (!m_Checkable)
|
||||
BOOST_THROW_EXCEPTION(ScriptError("Downtime '" + GetName() + "' references a host/service which doesn't exist.", GetDebugInfo()));
|
||||
@ -208,7 +206,7 @@ int Downtime::GetNextDowntimeID()
|
||||
return l_NextDowntimeID;
|
||||
}
|
||||
|
||||
String Downtime::AddDowntime(const Checkable::Ptr& checkable, const String& author,
|
||||
Downtime::Ptr Downtime::AddDowntime(const Checkable::Ptr& checkable, const String& author,
|
||||
const String& comment, double startTime, double endTime, bool fixed,
|
||||
const String& triggeredBy, double duration,
|
||||
const String& scheduledDowntime, const String& scheduledBy,
|
||||
@ -304,7 +302,7 @@ String Downtime::AddDowntime(const Checkable::Ptr& checkable, const String& auth
|
||||
<< "' and '" << Utility::FormatDateTime("%Y-%m-%d %H:%M:%S", endTime) << "', author: '"
|
||||
<< author << "', " << (fixed ? "fixed" : "flexible with " + Convert::ToString(duration) + "s duration");
|
||||
|
||||
return fullName;
|
||||
return downtime;
|
||||
}
|
||||
|
||||
void Downtime::RemoveDowntime(const String& id, bool cancelled, bool expired, const MessageOrigin::Ptr& origin)
|
||||
|
@ -45,7 +45,7 @@ public:
|
||||
|
||||
static int GetNextDowntimeID();
|
||||
|
||||
static String AddDowntime(const intrusive_ptr<Checkable>& checkable, const String& author,
|
||||
static Ptr AddDowntime(const intrusive_ptr<Checkable>& checkable, const String& author,
|
||||
const String& comment, double startTime, double endTime, bool fixed,
|
||||
const String& triggeredBy, double duration, const String& scheduledDowntime = String(),
|
||||
const String& scheduledBy = String(), const String& id = String(),
|
||||
|
@ -1055,7 +1055,7 @@ void ExternalCommandProcessor::ScheduleAndPropagateTriggeredHostDowntime(double,
|
||||
Log(LogNotice, "ExternalCommandProcessor")
|
||||
<< "Creating downtime for host " << host->GetName();
|
||||
|
||||
String parentDowntime = Downtime::AddDowntime(host, arguments[6], arguments[7],
|
||||
Downtime::Ptr parentDowntime = Downtime::AddDowntime(host, arguments[6], arguments[7],
|
||||
Convert::ToDouble(arguments[1]), Convert::ToDouble(arguments[2]),
|
||||
Convert::ToBool(is_fixed), triggeredBy, Convert::ToDouble(arguments[5]));
|
||||
|
||||
@ -1071,7 +1071,7 @@ void ExternalCommandProcessor::ScheduleAndPropagateTriggeredHostDowntime(double,
|
||||
|
||||
(void) Downtime::AddDowntime(child, arguments[6], arguments[7],
|
||||
Convert::ToDouble(arguments[1]), Convert::ToDouble(arguments[2]),
|
||||
Convert::ToBool(is_fixed), parentDowntime, Convert::ToDouble(arguments[5]));
|
||||
Convert::ToBool(is_fixed), parentDowntime->GetName(), Convert::ToDouble(arguments[5]));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -253,11 +253,10 @@ void ScheduledDowntime::CreateNextDowntime()
|
||||
return;
|
||||
}
|
||||
|
||||
String downtimeName = Downtime::AddDowntime(GetCheckable(), GetAuthor(), GetComment(),
|
||||
Downtime::Ptr downtime = Downtime::AddDowntime(GetCheckable(), GetAuthor(), GetComment(),
|
||||
segment.first, segment.second,
|
||||
GetFixed(), String(), GetDuration(), GetName(), GetName());
|
||||
|
||||
Downtime::Ptr downtime = Downtime::GetByName(downtimeName);
|
||||
String downtimeName = downtime->GetName();
|
||||
|
||||
int childOptions = Downtime::ChildOptionsFromValue(GetChildOptions());
|
||||
if (childOptions > 0) {
|
||||
@ -275,11 +274,11 @@ void ScheduledDowntime::CreateNextDowntime()
|
||||
Log(LogNotice, "ScheduledDowntime")
|
||||
<< "Scheduling downtime for child object " << child->GetName();
|
||||
|
||||
String childDowntimeName = Downtime::AddDowntime(child, GetAuthor(), GetComment(),
|
||||
Downtime::Ptr childDowntime = Downtime::AddDowntime(child, GetAuthor(), GetComment(),
|
||||
segment.first, segment.second, GetFixed(), triggerName, GetDuration(), GetName(), GetName());
|
||||
|
||||
Log(LogNotice, "ScheduledDowntime")
|
||||
<< "Add child downtime '" << childDowntimeName << "'.";
|
||||
<< "Add child downtime '" << childDowntime->GetName() << "'.";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user