mirror of https://github.com/Icinga/icinga2.git
Deactivate Livestatus listener before writing the state file
fixes #7660
This commit is contained in:
parent
79b0c13dfb
commit
493620a0ac
|
@ -70,6 +70,7 @@ void LivestatusListener::Start(void)
|
|||
|
||||
if (GetSocketType() == "tcp") {
|
||||
TcpSocket::Ptr socket = new TcpSocket();
|
||||
|
||||
try {
|
||||
socket->Bind(GetBindHost(), GetBindPort(), AF_UNSPEC);
|
||||
} catch (std::exception&) {
|
||||
|
@ -78,6 +79,8 @@ void LivestatusListener::Start(void)
|
|||
return;
|
||||
}
|
||||
|
||||
m_Listener = socket;
|
||||
|
||||
boost::thread thread(boost::bind(&LivestatusListener::ServerThreadProc, this, socket));
|
||||
thread.detach();
|
||||
Log(LogInformation, "LivestatusListener")
|
||||
|
@ -86,6 +89,7 @@ void LivestatusListener::Start(void)
|
|||
else if (GetSocketType() == "unix") {
|
||||
#ifndef _WIN32
|
||||
UnixSocket::Ptr socket = new UnixSocket();
|
||||
|
||||
try {
|
||||
socket->Bind(GetSocketPath());
|
||||
} catch (std::exception&) {
|
||||
|
@ -103,6 +107,8 @@ void LivestatusListener::Start(void)
|
|||
return;
|
||||
}
|
||||
|
||||
m_Listener = socket;
|
||||
|
||||
boost::thread thread(boost::bind(&LivestatusListener::ServerThreadProc, this, socket));
|
||||
thread.detach();
|
||||
Log(LogInformation, "LivestatusListener")
|
||||
|
@ -115,6 +121,13 @@ void LivestatusListener::Start(void)
|
|||
}
|
||||
}
|
||||
|
||||
void LivestatusListener::Stop(void)
|
||||
{
|
||||
DynamicObject::Stop();
|
||||
|
||||
m_Listener->Close();
|
||||
}
|
||||
|
||||
int LivestatusListener::GetClientsConnected(void)
|
||||
{
|
||||
boost::mutex::scoped_lock lock(l_ComponentMutex);
|
||||
|
|
|
@ -48,10 +48,13 @@ public:
|
|||
|
||||
protected:
|
||||
virtual void Start(void);
|
||||
virtual void Stop(void);
|
||||
|
||||
private:
|
||||
void ServerThreadProc(const Socket::Ptr& server);
|
||||
void ClientHandler(const Socket::Ptr& client);
|
||||
|
||||
Socket::Ptr m_Listener;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue