mirror of https://github.com/Icinga/icinga2.git
parent
0eb6e174c8
commit
0d4e92015c
|
@ -81,8 +81,8 @@ void LivestatusListener::Start(void)
|
||||||
|
|
||||||
m_Listener = socket;
|
m_Listener = socket;
|
||||||
|
|
||||||
boost::thread thread(boost::bind(&LivestatusListener::ServerThreadProc, this, socket));
|
m_Thread = boost::thread(boost::bind(&LivestatusListener::ServerThreadProc, this));
|
||||||
thread.detach();
|
|
||||||
Log(LogInformation, "LivestatusListener")
|
Log(LogInformation, "LivestatusListener")
|
||||||
<< "Created TCP socket listening on host '" << GetBindHost() << "' port '" << GetBindPort() << "'.";
|
<< "Created TCP socket listening on host '" << GetBindHost() << "' port '" << GetBindPort() << "'.";
|
||||||
}
|
}
|
||||||
|
@ -109,8 +109,8 @@ void LivestatusListener::Start(void)
|
||||||
|
|
||||||
m_Listener = socket;
|
m_Listener = socket;
|
||||||
|
|
||||||
boost::thread thread(boost::bind(&LivestatusListener::ServerThreadProc, this, socket));
|
m_Thread = boost::thread(boost::bind(&LivestatusListener::ServerThreadProc, this));
|
||||||
thread.detach();
|
|
||||||
Log(LogInformation, "LivestatusListener")
|
Log(LogInformation, "LivestatusListener")
|
||||||
<< "Created UNIX socket in '" << GetSocketPath() << "'.";
|
<< "Created UNIX socket in '" << GetSocketPath() << "'.";
|
||||||
#else
|
#else
|
||||||
|
@ -126,6 +126,9 @@ void LivestatusListener::Stop(void)
|
||||||
DynamicObject::Stop();
|
DynamicObject::Stop();
|
||||||
|
|
||||||
m_Listener->Close();
|
m_Listener->Close();
|
||||||
|
|
||||||
|
if (m_Thread.joinable())
|
||||||
|
m_Thread.join();
|
||||||
}
|
}
|
||||||
|
|
||||||
int LivestatusListener::GetClientsConnected(void)
|
int LivestatusListener::GetClientsConnected(void)
|
||||||
|
@ -142,19 +145,21 @@ int LivestatusListener::GetConnections(void)
|
||||||
return l_Connections;
|
return l_Connections;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LivestatusListener::ServerThreadProc(const Socket::Ptr& server)
|
void LivestatusListener::ServerThreadProc(void)
|
||||||
{
|
{
|
||||||
server->Listen();
|
m_Listener->Listen();
|
||||||
|
|
||||||
for (;;) {
|
|
||||||
try {
|
try {
|
||||||
Socket::Ptr client = server->Accept();
|
for (;;) {
|
||||||
|
Socket::Ptr client = m_Listener->Accept();
|
||||||
Log(LogNotice, "LivestatusListener", "Client connected");
|
Log(LogNotice, "LivestatusListener", "Client connected");
|
||||||
Utility::QueueAsyncCallback(boost::bind(&LivestatusListener::ClientHandler, this, client), LowLatencyScheduler);
|
Utility::QueueAsyncCallback(boost::bind(&LivestatusListener::ClientHandler, this, client), LowLatencyScheduler);
|
||||||
|
}
|
||||||
} catch (std::exception&) {
|
} catch (std::exception&) {
|
||||||
Log(LogCritical, "ListenerListener", "Cannot accept new connection.");
|
Log(LogCritical, "ListenerListener", "Cannot accept new connection.");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
m_Listener->Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LivestatusListener::ClientHandler(const Socket::Ptr& client)
|
void LivestatusListener::ClientHandler(const Socket::Ptr& client)
|
||||||
|
|
|
@ -51,10 +51,11 @@ protected:
|
||||||
virtual void Stop(void);
|
virtual void Stop(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ServerThreadProc(const Socket::Ptr& server);
|
void ServerThreadProc(void);
|
||||||
void ClientHandler(const Socket::Ptr& client);
|
void ClientHandler(const Socket::Ptr& client);
|
||||||
|
|
||||||
Socket::Ptr m_Listener;
|
Socket::Ptr m_Listener;
|
||||||
|
boost::thread m_Thread;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue