From 8f061ae80e614c02ffb3e604792a06c8c7c553d9 Mon Sep 17 00:00:00 2001
From: Noah Hilverling <noah.hilverling@icinga.com>
Date: Wed, 4 Mar 2020 10:55:07 +0100
Subject: [PATCH] Fix OnHostProblemChanged signal

---
 lib/icinga/checkable-check.cpp | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/lib/icinga/checkable-check.cpp b/lib/icinga/checkable-check.cpp
index f8f3eeca2..d5a5f1a92 100644
--- a/lib/icinga/checkable-check.cpp
+++ b/lib/icinga/checkable-check.cpp
@@ -248,20 +248,7 @@ void Checkable::ProcessCheckResult(const CheckResult::Ptr& cr, const MessageOrig
 	SetCheckAttempt(attempt);
 
 	ServiceState new_state = cr->GetState();
-
-	if (service) {
-		SetStateRaw(new_state);
-	} else {
-		bool wasProblem = GetProblem();
-
-		SetStateRaw(new_state);
-
-		if (GetProblem() != wasProblem) {
-			for (auto& service : host->GetServices()) {
-				Service::OnHostProblemChanged(service, cr, origin);
-			}
-		}
-	}
+	SetStateRaw(new_state);
 
 	bool stateChange;
 
@@ -362,7 +349,20 @@ void Checkable::ProcessCheckResult(const CheckResult::Ptr& cr, const MessageOrig
 	cr->SetVarsAfter(vars_after);
 
 	olock.Lock();
-	SetLastCheckResult(cr);
+
+	if (service) {
+		SetLastCheckResult(cr);
+	} else {
+		bool wasProblem = GetProblem();
+
+		SetLastCheckResult(cr);
+
+		if (GetProblem() != wasProblem) {
+			for (auto& service : host->GetServices()) {
+				Service::OnHostProblemChanged(service, cr, origin);
+			}
+		}
+	}
 
 	bool was_flapping = IsFlapping();