This commit is contained in:
Alexander A. Klimov 2024-05-07 12:41:22 +02:00
parent 1a756f2d85
commit 3e1fd1da14
3 changed files with 16 additions and 0 deletions

View File

@ -98,6 +98,12 @@ Checkable::ProcessingResult Checkable::ProcessCheckResult(const CheckResult::Ptr
{
using Result = Checkable::ProcessingResult;
std::shared_lock<std::shared_timed_mutex> preventStop (m_ProcessCheckResultMutex, std::try_to_lock);
if (!preventStop) {
return Result::CheckableInactive;
}
{
ObjectLock olock(this);
m_CheckRunning = false;

View File

@ -113,6 +113,13 @@ void Checkable::Start(bool runtimeCreated)
});
}
void Checkable::Stop(bool runtimeRemoved)
{
m_ProcessCheckResultMutex.lock();
ObjectImpl<Checkable>::Stop(runtimeRemoved);
}
void Checkable::AddGroup(const String& name)
{
std::unique_lock<std::mutex> lock(m_CheckableMutex);

View File

@ -18,6 +18,7 @@
#include <cstdint>
#include <functional>
#include <limits>
#include <shared_mutex>
namespace icinga
{
@ -210,11 +211,13 @@ public:
protected:
void Start(bool runtimeCreated) override;
void Stop(bool runtimeRemoved) override;
void OnConfigLoaded() override;
void OnAllConfigLoaded() override;
private:
mutable std::mutex m_CheckableMutex;
mutable std::shared_timed_mutex m_ProcessCheckResultMutex;
bool m_CheckRunning{false};
long m_SchedulingOffset;