]> granicus.if.org Git - icinga2/commitdiff
Fix deadlock in GraphiteWriter 6770/head
authorMichael Insel <michael@insel.email>
Mon, 12 Nov 2018 19:09:44 +0000 (19:09 +0000)
committerMichael Insel <michael@insel.email>
Mon, 12 Nov 2018 19:12:40 +0000 (20:12 +0100)
This fixes a deadlock in the GraphiteWriter feature, which is visible
during the reload process. The reload thread waits for the
GraphiteWriter to finish, but the GraphiteWriter can't finish because
it's stuck in `SendMetric()` waiting for a lock which is hold by the
reload thread.

lib/perfdata/graphitewriter.cpp
lib/perfdata/graphitewriter.hpp

index a01f6c48bf6329e79f525c087270b4930ab03aca..1b6461d51378fb9d504e95890bd5b220cd3c02e0 100644 (file)
@@ -299,7 +299,7 @@ void GraphiteWriter::SendMetric(const String& prefix, const String& name, double
        msgbuf << "\n";
        String metric = msgbuf.str();
 
-       ObjectLock olock(this);
+       boost::mutex::scoped_lock lock(m_StreamMutex);
 
        if (!GetConnected())
                return;
index 6934d13b35d86d3c0209b6470b512a190f14e54b..ec4c5bbfe0f736ae712d0449c5351c8679a0d9f5 100644 (file)
@@ -27,6 +27,7 @@
 #include "base/timer.hpp"
 #include "base/workqueue.hpp"
 #include <fstream>
+#include <boost/thread/mutex.hpp>
 
 namespace icinga
 {
@@ -54,6 +55,7 @@ protected:
 
 private:
        Stream::Ptr m_Stream;
+       boost::mutex m_StreamMutex;
        WorkQueue m_WorkQueue{10000000, 1};
 
        Timer::Ptr m_ReconnectTimer;