From 1e5fc993a4fa3f3f5d242a08aa61094e2c3893ab Mon Sep 17 00:00:00 2001
From: Michael Carlberg <c@rlberg.se>
Date: Tue, 21 Jun 2016 16:34:19 +0200
Subject: [PATCH] fix: Revert nested locking in module destruct

---
 include/modules/base.hpp | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/include/modules/base.hpp b/include/modules/base.hpp
index ae28161e..846b0fb9 100644
--- a/include/modules/base.hpp
+++ b/include/modules/base.hpp
@@ -129,20 +129,16 @@ namespace modules
         if (this->enabled())
           this->stop();
 
-        std::lock_guard<concurrency::SpinLock> lck(this->broadcast_lock);
+        std::lock_guard<concurrency::SpinLock> lck(this->update_lock);
         {
-          std::lock_guard<concurrency::SpinLock> lck(this->update_lock);
-          {
-            std::lock_guard<concurrency::SpinLock> lck(this->output_lock);
-            {
-              for (auto &&t : this->threads) {
-                if (t.joinable())
-                  t.join();
-                else
-                  log_warning("["+ ConstCastModule(ModuleImpl).name() +"] Runner thread not joinable");
-              }
-            }
+          for (auto &&t : this->threads) {
+            if (t.joinable())
+              t.join();
+            else
+              log_warning("["+ ConstCastModule(ModuleImpl).name() +"] Runner thread not joinable");
           }
+
+          this->threads.clear();
         }
 
         log_trace(name());