]> granicus.if.org Git - icinga2/commitdiff
livestatus: close socket on component Stop()
authorMichael Friedrich <michael.friedrich@netways.de>
Wed, 10 Jul 2013 12:19:01 +0000 (14:19 +0200)
committerMichael Friedrich <michael.friedrich@netways.de>
Wed, 10 Jul 2013 12:19:01 +0000 (14:19 +0200)
refs #4376

components/livestatus/component.cpp
components/livestatus/component.h

index bc10ca534b1549fa2e456dc16b9e26e4b08c9911..a43d2d2f10b814fb9ee0c5ad12f7bbd029e96e79 100644 (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
index e197f656a09f78d2e782ffed060a162ee0caf848..e118aad15ab4795d26273aec65904aa78f10b3ba 100644 (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;