Skip to content

Commit 7b5eac7

Browse files
committed
Checkable#ProcessCheckResult(): discard CR or delay its producers shutdown
1 parent b2d946e commit 7b5eac7

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

lib/icinga/checkable-check.cpp

Lines changed: 9 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

@@ -134,6 +135,14 @@ Checkable::ProcessingResult Checkable::ProcessCheckResult(const CheckResult::Ptr
134135
cr->SetCheckSource(command_endpoint->GetName());
135136
}
136137

138+
std::shared_lock producerLock (*cr->GetProducer(), std::try_to_lock);
139+
140+
if (!producerLock) {
141+
// Discard the check result to not delay the current reload.
142+
// We'll re-run the check immediately after the reload.
143+
return Result::CheckableInactive;
144+
}
145+
137146
/* agent checks go through the api */
138147
if (command_endpoint && GetExtension("agent_check")) {
139148
ApiListener::Ptr listener = ApiListener::GetInstance();

lib/icinga/checkresult.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ class CheckResult final : public ObjectImpl<CheckResult>
4848
{
4949
}
5050

51+
const CheckResultProducer::Ptr& GetProducer() const noexcept
52+
{
53+
return m_Producer;
54+
}
55+
5156
double CalculateExecutionTime() const;
5257
double CalculateLatency() const;
5358

0 commit comments

Comments
 (0)