mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-30 17:14:25 +02:00
Add a StoppableWaitGroup, and join it on #Stop(), to:
ApiListener CheckerComponent ExternalCommandListener LivestatusListener
This commit is contained in:
parent
18fb93fc11
commit
c7cca7b460
@ -81,6 +81,7 @@ void CheckerComponent::Stop(bool runtimeRemoved)
|
||||
m_CV.notify_all();
|
||||
}
|
||||
|
||||
m_WaitGroup->Join();
|
||||
m_ResultTimer->Stop(true);
|
||||
m_Thread.join();
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "base/configobject.hpp"
|
||||
#include "base/timer.hpp"
|
||||
#include "base/utility.hpp"
|
||||
#include "base/wait-group.hpp"
|
||||
#include <boost/multi_index_container.hpp>
|
||||
#include <boost/multi_index/ordered_index.hpp>
|
||||
#include <boost/multi_index/key_extractors.hpp>
|
||||
@ -77,6 +78,7 @@ private:
|
||||
CheckableSet m_IdleCheckables;
|
||||
CheckableSet m_PendingCheckables;
|
||||
|
||||
StoppableWaitGroup::Ptr m_WaitGroup = new StoppableWaitGroup();
|
||||
Timer::Ptr m_ResultTimer;
|
||||
|
||||
void CheckThreadProc();
|
||||
|
@ -50,6 +50,8 @@ void ExternalCommandListener::Start(bool runtimeCreated)
|
||||
*/
|
||||
void ExternalCommandListener::Stop(bool runtimeRemoved)
|
||||
{
|
||||
m_WaitGroup->Join();
|
||||
|
||||
Log(LogInformation, "ExternalCommandListener")
|
||||
<< "'" << GetName() << "' stopped.";
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
#include "compat/externalcommandlistener-ti.hpp"
|
||||
#include "base/objectlock.hpp"
|
||||
#include "base/wait-group.hpp"
|
||||
#include "base/timer.hpp"
|
||||
#include "base/utility.hpp"
|
||||
#include <thread>
|
||||
@ -29,6 +30,8 @@ protected:
|
||||
void Stop(bool runtimeRemoved) override;
|
||||
|
||||
private:
|
||||
StoppableWaitGroup::Ptr m_WaitGroup = new StoppableWaitGroup();
|
||||
|
||||
#ifndef _WIN32
|
||||
std::thread m_CommandThread;
|
||||
|
||||
|
@ -112,6 +112,7 @@ void LivestatusListener::Stop(bool runtimeRemoved)
|
||||
<< "'" << GetName() << "' stopped.";
|
||||
|
||||
m_Listener->Close();
|
||||
m_WaitGroup->Join();
|
||||
|
||||
if (m_Thread.joinable())
|
||||
m_Thread.join();
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "livestatus/livestatuslistener-ti.hpp"
|
||||
#include "livestatus/livestatusquery.hpp"
|
||||
#include "base/socket.hpp"
|
||||
#include "base/wait-group.hpp"
|
||||
#include <thread>
|
||||
|
||||
using namespace icinga;
|
||||
@ -40,6 +41,7 @@ private:
|
||||
|
||||
Socket::Ptr m_Listener;
|
||||
std::thread m_Thread;
|
||||
StoppableWaitGroup::Ptr m_WaitGroup = new StoppableWaitGroup();
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -368,6 +368,7 @@ void ApiListener::Stop(bool runtimeDeleted)
|
||||
m_Timer->Stop(true);
|
||||
m_RenewOwnCertTimer->Stop(true);
|
||||
|
||||
m_WaitGroup->Join();
|
||||
ObjectImpl<ApiListener>::Stop(runtimeDeleted);
|
||||
|
||||
Log(LogInformation, "ApiListener")
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "base/tcpsocket.hpp"
|
||||
#include "base/tlsstream.hpp"
|
||||
#include "base/threadpool.hpp"
|
||||
#include "base/wait-group.hpp"
|
||||
#include <atomic>
|
||||
#include <boost/asio/io_context.hpp>
|
||||
#include <boost/asio/ip/tcp.hpp>
|
||||
@ -177,6 +178,7 @@ private:
|
||||
Timer::Ptr m_RenewOwnCertTimer;
|
||||
|
||||
Endpoint::Ptr m_LocalEndpoint;
|
||||
StoppableWaitGroup::Ptr m_WaitGroup = new StoppableWaitGroup();
|
||||
|
||||
static ApiListener::Ptr m_Instance;
|
||||
static std::atomic<bool> m_UpdatedObjectAuthority;
|
||||
|
Loading…
x
Reference in New Issue
Block a user