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") {
|
if (GetSocketType() == "tcp") {
|
||||||
TcpSocket::Ptr socket = new TcpSocket();
|
TcpSocket::Ptr socket = new TcpSocket();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
socket->Bind(GetBindHost(), GetBindPort(), AF_UNSPEC);
|
socket->Bind(GetBindHost(), GetBindPort(), AF_UNSPEC);
|
||||||
} catch (std::exception&) {
|
} catch (std::exception&) {
|
||||||
|
@ -78,6 +79,8 @@ void LivestatusListener::Start(void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_Listener = socket;
|
||||||
|
|
||||||
boost::thread thread(boost::bind(&LivestatusListener::ServerThreadProc, this, socket));
|
boost::thread thread(boost::bind(&LivestatusListener::ServerThreadProc, this, socket));
|
||||||
thread.detach();
|
thread.detach();
|
||||||
Log(LogInformation, "LivestatusListener")
|
Log(LogInformation, "LivestatusListener")
|
||||||
|
@ -86,6 +89,7 @@ void LivestatusListener::Start(void)
|
||||||
else if (GetSocketType() == "unix") {
|
else if (GetSocketType() == "unix") {
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
UnixSocket::Ptr socket = new UnixSocket();
|
UnixSocket::Ptr socket = new UnixSocket();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
socket->Bind(GetSocketPath());
|
socket->Bind(GetSocketPath());
|
||||||
} catch (std::exception&) {
|
} catch (std::exception&) {
|
||||||
|
@ -103,6 +107,8 @@ void LivestatusListener::Start(void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_Listener = socket;
|
||||||
|
|
||||||
boost::thread thread(boost::bind(&LivestatusListener::ServerThreadProc, this, socket));
|
boost::thread thread(boost::bind(&LivestatusListener::ServerThreadProc, this, socket));
|
||||||
thread.detach();
|
thread.detach();
|
||||||
Log(LogInformation, "LivestatusListener")
|
Log(LogInformation, "LivestatusListener")
|
||||||
|
@ -115,6 +121,13 @@ void LivestatusListener::Start(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LivestatusListener::Stop(void)
|
||||||
|
{
|
||||||
|
DynamicObject::Stop();
|
||||||
|
|
||||||
|
m_Listener->Close();
|
||||||
|
}
|
||||||
|
|
||||||
int LivestatusListener::GetClientsConnected(void)
|
int LivestatusListener::GetClientsConnected(void)
|
||||||
{
|
{
|
||||||
boost::mutex::scoped_lock lock(l_ComponentMutex);
|
boost::mutex::scoped_lock lock(l_ComponentMutex);
|
||||||
|
|
|
@ -48,10 +48,13 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void Start(void);
|
virtual void Start(void);
|
||||||
|
virtual void Stop(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ServerThreadProc(const Socket::Ptr& server);
|
void ServerThreadProc(const Socket::Ptr& server);
|
||||||
void ClientHandler(const Socket::Ptr& client);
|
void ClientHandler(const Socket::Ptr& client);
|
||||||
|
|
||||||
|
Socket::Ptr m_Listener;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue