]> granicus.if.org Git - icinga2/commitdiff
DB IDO: Fix possible crash with program status updates before IcingaApplication is... 7310/head
authorMichael Friedrich <michael.friedrich@icinga.com>
Thu, 11 Jul 2019 13:50:52 +0000 (15:50 +0200)
committerMichael Friedrich <michael.friedrich@icinga.com>
Thu, 11 Jul 2019 14:06:27 +0000 (16:06 +0200)
lib/db_ido/dbconnection.cpp

index 0265dad05075386dff5f517d5dcddb6ee60281d6..0ae9a80ca91181a9e7a79f791592f47843711e79 100644 (file)
@@ -132,6 +132,11 @@ void DbConnection::InsertRuntimeVariable(const String& key, const Value& value)
 
 void DbConnection::UpdateProgramStatus()
 {
+       IcingaApplication::Ptr icingaApplication = IcingaApplication::GetInstance();
+
+       if (!icingaApplication)
+               return;
+
        Log(LogNotice, "DbConnection")
                << "Updating programstatus table.";
 
@@ -149,18 +154,18 @@ void DbConnection::UpdateProgramStatus()
                { "status_update_time", DbValue::FromTimestamp(Utility::GetTime()) },
                { "program_start_time", DbValue::FromTimestamp(Application::GetStartTime()) },
                { "is_currently_running", 1 },
-               { "endpoint_name", IcingaApplication::GetInstance()->GetNodeName() },
+               { "endpoint_name", icingaApplication->GetNodeName() },
                { "process_id", Utility::GetPid() },
                { "daemon_mode", 1 },
                { "last_command_check", DbValue::FromTimestamp(Utility::GetTime()) },
-               { "notifications_enabled", (IcingaApplication::GetInstance()->GetEnableNotifications() ? 1 : 0) },
-               { "active_host_checks_enabled", (IcingaApplication::GetInstance()->GetEnableHostChecks() ? 1 : 0) },
+               { "notifications_enabled", (icingaApplication->GetEnableNotifications() ? 1 : 0) },
+               { "active_host_checks_enabled", (icingaApplication->GetEnableHostChecks() ? 1 : 0) },
                { "passive_host_checks_enabled", 1 },
-               { "active_service_checks_enabled", (IcingaApplication::GetInstance()->GetEnableServiceChecks() ? 1 : 0) },
+               { "active_service_checks_enabled", (icingaApplication->GetEnableServiceChecks() ? 1 : 0) },
                { "passive_service_checks_enabled", 1 },
-               { "event_handlers_enabled", (IcingaApplication::GetInstance()->GetEnableEventHandlers() ? 1 : 0) },
-               { "flap_detection_enabled", (IcingaApplication::GetInstance()->GetEnableFlapping() ? 1 : 0) },
-               { "process_performance_data", (IcingaApplication::GetInstance()->GetEnablePerfdata() ? 1 : 0) }
+               { "event_handlers_enabled", (icingaApplication->GetEnableEventHandlers() ? 1 : 0) },
+               { "flap_detection_enabled", (icingaApplication->GetEnableFlapping() ? 1 : 0) },
+               { "process_performance_data", (icingaApplication->GetEnablePerfdata() ? 1 : 0) }
        });
 
        query1.WhereCriteria = new Dictionary({