From aa549795b3dfaac8d9fd04c788f2e70464848617 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Blin?=
 <sebastien.blin@savoirfairelinux.com>
Date: Mon, 9 Mar 2020 15:05:05 -0400
Subject: [PATCH] manager: remove IceTransportFactory after the io pool

This avoids to crash when freeing the ressources, and wait that the
ConnectionManager has finished to release all its resources.

Change-Id: Ic6776f5c8820cca20b6d098df78d05b91d4c4aad
Gitlab: #209
---
 src/manager.cpp | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/manager.cpp b/src/manager.cpp
index 00cd613b46..92bc03187c 100644
--- a/src/manager.cpp
+++ b/src/manager.cpp
@@ -838,13 +838,17 @@ Manager::finish() noexcept
             pimpl_->audiodriver_.reset();
         }
 
-        pimpl_->ice_tf_.reset();
 
         // Flush remaining tasks (free lambda' with capture)
         pimpl_->scheduler_.stop();
         dht::ThreadPool::io().join();
         dht::ThreadPool::computation().join();
 
+        // IceTransportFactory should be stopped after the io pool
+        // as some ICE are destroyed in a ioPool (see ConnectionManager)
+        // Also, it must be called before pj_shutdown to avoid any problem
+        pimpl_->ice_tf_.reset();
+
         pj_shutdown();
 
         if (!pimpl_->ioContext_->stopped()){
-- 
GitLab