From a8eab3536a3f0f2a35416cae4ec6ddd51eb50121 Mon Sep 17 00:00:00 2001
From: Guillaume Roguez <guillaume.roguez@savoirfairelinux.com>
Date: Tue, 20 Jun 2017 23:19:28 -0400
Subject: [PATCH] manager: free some lambdas' capture ressources

tasks, event handlers use lambdas as callback.
These lambdas may have captured some ressources
that need to be released before the some others, like pjsip.

this patch clears all this tasks/handlers during the finish().

Change-Id: I5449fe8923c06ad85c16bbdf584f686a4ba94188
---
 src/manager.cpp | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/manager.cpp b/src/manager.cpp
index b7c94832d3..008eb9810b 100644
--- a/src/manager.cpp
+++ b/src/manager.cpp
@@ -789,6 +789,12 @@ Manager::finish() noexcept
         }
 
         pimpl_->ice_tf_.reset();
+
+        // Flush remaining tasks (free lambda' with capture)
+        pimpl_->pendingTaskList_.clear();
+        pimpl_->scheduledTasks_.clear();
+        pimpl_->eventHandlerMap_.clear();
+
         pj_shutdown();
         ThreadPool::instance().join();
     } catch (const VoipLinkException &err) {
-- 
GitLab