Skip to content

Commit d9481fd

Browse files
committed
*#Stop(): wait for own Checkable#ProcessCheckResult()s to finish
1 parent d672039 commit d9481fd

8 files changed

+18
-4
lines changed

lib/checker/checkercomponent.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ void CheckerComponent::OnConfigLoaded()
6060
void CheckerComponent::Start(bool runtimeCreated)
6161
{
6262
ObjectImpl<CheckerComponent>::Start(runtimeCreated);
63+
CheckResultProducerComponent::Start();
6364

6465
Log(LogInformation, "CheckerComponent")
6566
<< "'" << GetName() << "' started.";
@@ -81,6 +82,7 @@ void CheckerComponent::Stop(bool runtimeRemoved)
8182
m_CV.notify_all();
8283
}
8384

85+
CheckResultProducerComponent::Stop();
8486
m_ResultTimer->Stop(true);
8587
m_Thread.join();
8688

lib/checker/checkercomponent.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "base/configobject.hpp"
99
#include "base/timer.hpp"
1010
#include "base/utility.hpp"
11+
#include "remote/crproducer.hpp"
1112
#include <boost/multi_index_container.hpp>
1213
#include <boost/multi_index/ordered_index.hpp>
1314
#include <boost/multi_index/key_extractors.hpp>
@@ -46,7 +47,7 @@ struct CheckableNextCheckExtractor
4647
/**
4748
* @ingroup checker
4849
*/
49-
class CheckerComponent final : public ObjectImpl<CheckerComponent>
50+
class CheckerComponent final : public ObjectImpl<CheckerComponent>, public CheckResultProducerComponent
5051
{
5152
public:
5253
DECLARE_OBJECT(CheckerComponent);

lib/compat/externalcommandlistener.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ void ExternalCommandListener::StatsFunc(const Dictionary::Ptr& status, const Arr
3232
void ExternalCommandListener::Start(bool runtimeCreated)
3333
{
3434
ObjectImpl<ExternalCommandListener>::Start(runtimeCreated);
35+
CheckResultProducerComponent::Start();
3536

3637
Log(LogInformation, "ExternalCommandListener")
3738
<< "'" << GetName() << "' started.";
@@ -50,6 +51,8 @@ void ExternalCommandListener::Start(bool runtimeCreated)
5051
*/
5152
void ExternalCommandListener::Stop(bool runtimeRemoved)
5253
{
54+
CheckResultProducerComponent::Stop();
55+
5356
Log(LogInformation, "ExternalCommandListener")
5457
<< "'" << GetName() << "' stopped.";
5558

lib/compat/externalcommandlistener.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "base/objectlock.hpp"
88
#include "base/timer.hpp"
99
#include "base/utility.hpp"
10+
#include "remote/crproducer.hpp"
1011
#include <thread>
1112
#include <iostream>
1213

@@ -16,7 +17,7 @@ namespace icinga
1617
/**
1718
* @ingroup compat
1819
*/
19-
class ExternalCommandListener final : public ObjectImpl<ExternalCommandListener>
20+
class ExternalCommandListener final : public ObjectImpl<ExternalCommandListener>, public CheckResultProducerComponent
2021
{
2122
public:
2223
DECLARE_OBJECT(ExternalCommandListener);

lib/livestatus/livestatuslistener.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ void LivestatusListener::StatsFunc(const Dictionary::Ptr& status, const Array::P
4747
void LivestatusListener::Start(bool runtimeCreated)
4848
{
4949
ObjectImpl<LivestatusListener>::Start(runtimeCreated);
50+
CheckResultProducerComponent::Start();
5051

5152
Log(LogInformation, "LivestatusListener")
5253
<< "'" << GetName() << "' started.";
@@ -112,6 +113,7 @@ void LivestatusListener::Stop(bool runtimeRemoved)
112113
<< "'" << GetName() << "' stopped.";
113114

114115
m_Listener->Close();
116+
CheckResultProducerComponent::Stop();
115117

116118
if (m_Thread.joinable())
117119
m_Thread.join();

lib/livestatus/livestatuslistener.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "livestatus/livestatuslistener-ti.hpp"
88
#include "livestatus/livestatusquery.hpp"
99
#include "base/socket.hpp"
10+
#include "remote/crproducer.hpp"
1011
#include <thread>
1112

1213
using namespace icinga;
@@ -17,7 +18,7 @@ namespace icinga
1718
/**
1819
* @ingroup livestatus
1920
*/
20-
class LivestatusListener final : public ObjectImpl<LivestatusListener>
21+
class LivestatusListener final : public ObjectImpl<LivestatusListener>, public CheckResultProducerComponent
2122
{
2223
public:
2324
DECLARE_OBJECT(LivestatusListener);

lib/remote/apilistener.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,8 @@ void ApiListener::OnAllConfigLoaded()
239239
*/
240240
void ApiListener::Start(bool runtimeCreated)
241241
{
242+
CheckResultProducerComponent::Start();
243+
242244
Log(LogInformation, "ApiListener")
243245
<< "'" << GetName() << "' started.";
244246

@@ -368,6 +370,7 @@ void ApiListener::Stop(bool runtimeDeleted)
368370
m_Timer->Stop(true);
369371
m_RenewOwnCertTimer->Stop(true);
370372

373+
CheckResultProducerComponent::Stop();
371374
ObjectImpl<ApiListener>::Stop(runtimeDeleted);
372375

373376
Log(LogInformation, "ApiListener")

lib/remote/apilistener.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#define APILISTENER_H
55

66
#include "remote/apilistener-ti.hpp"
7+
#include "remote/crproducer.hpp"
78
#include "remote/jsonrpcconnection.hpp"
89
#include "remote/httpserverconnection.hpp"
910
#include "remote/endpoint.hpp"
@@ -74,7 +75,7 @@ enum class ApiCapabilities : uint_fast64_t
7475
/**
7576
* @ingroup remote
7677
*/
77-
class ApiListener final : public ObjectImpl<ApiListener>
78+
class ApiListener final : public ObjectImpl<ApiListener>, public CheckResultProducerComponent
7879
{
7980
public:
8081
DECLARE_OBJECT(ApiListener);

0 commit comments

Comments
 (0)