Skip to content

Commit a4d52af

Browse files
committed
Checkable#ProcessCheckResult(): discard CR or delay its producers shutdown
1 parent d2dea14 commit a4d52af

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

lib/icinga/checkable-check.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "base/convert.hpp"
1515
#include "base/utility.hpp"
1616
#include "base/context.hpp"
17+
#include <shared_mutex>
1718

1819
using namespace icinga;
1920

@@ -106,6 +107,9 @@ Checkable::ProcessingResult Checkable::ProcessCheckResult(const CheckResult::Ptr
106107
if (!cr)
107108
return Result::NoCheckResult;
108109

110+
if (!producer)
111+
return Result::NoCheckResult;
112+
109113
double now = Utility::GetTime();
110114

111115
if (cr->GetScheduleStart() == 0)
@@ -134,6 +138,14 @@ Checkable::ProcessingResult Checkable::ProcessCheckResult(const CheckResult::Ptr
134138
cr->SetCheckSource(command_endpoint->GetName());
135139
}
136140

141+
std::shared_lock producerLock (*producer, std::try_to_lock);
142+
143+
if (!producerLock) {
144+
// Discard the check result to not delay the current reload.
145+
// We'll re-run the check immediately after the reload.
146+
return Result::CheckableInactive;
147+
}
148+
137149
/* agent checks go through the api */
138150
if (command_endpoint && GetExtension("agent_check")) {
139151
ApiListener::Ptr listener = ApiListener::GetInstance();

0 commit comments

Comments
 (0)