livestatus: close socket on component Stop()

refs #4376
This commit is contained in:
Michael Friedrich 2013-07-10 14:19:01 +02:00
parent ff61df9d71
commit 8033586f66
2 changed files with 18 additions and 2 deletions

View File

@ -51,8 +51,20 @@ void LivestatusComponent::Start(void)
m_Listener = socket;
boost::thread thread(boost::bind(&LivestatusComponent::ServerThreadProc, this, socket));
thread.detach();
m_Thread = boost::thread(boost::bind(&LivestatusComponent::ServerThreadProc, this, socket));
m_Thread.detach();
}
/**
* Stops the component.
*/
void LivestatusComponent::Stop(void)
{
m_Listener->Close();
Log(LogInformation, "livestatus", "Socket closed.");
m_Thread.join();
}
String LivestatusComponent::GetSocketPath(void) const

View File

@ -23,6 +23,7 @@
#include "livestatus/query.h"
#include "base/dynamicobject.h"
#include "base/socket.h"
#include <boost/thread/thread.hpp>
using namespace icinga;
@ -38,10 +39,13 @@ public:
LivestatusComponent(const Dictionary::Ptr& serializedUpdate);
virtual void Start(void);
virtual void Stop(void);
String GetSocketPath(void) const;
private:
boost::thread m_Thread;
Attribute<String> m_SocketPath;
Socket::Ptr m_Listener;