From 9d470d99346aa4689e681b42bf13318d456837f9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Blin?=
 <sebastien.blin@savoirfairelinux.com>
Date: Thu, 5 Mar 2020 16:13:49 -0500
Subject: [PATCH] jamiaccount: avoid ice destruction on main thread

Change-Id: I120daad5e1e96d76c61c1e9d69ba4516286faa91
Gitlab: #205
---
 src/jamidht/jamiaccount.cpp | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/jamidht/jamiaccount.cpp b/src/jamidht/jamiaccount.cpp
index d9086cc1ec..df75d68763 100644
--- a/src/jamidht/jamiaccount.cpp
+++ b/src/jamidht/jamiaccount.cpp
@@ -1519,6 +1519,11 @@ JamiAccount::handlePendingCall(PendingCall& pc, bool incoming)
     if (!tcp_finished) {
         JAMI_DBG("TCP not running, will use SIP over UDP");
         best_transport = pc.ice_sp;
+        // Move the ice destruction in its own thread to avoid
+        // slow operations on main thread
+        dht::ThreadPool::io().run([ice = std::move(pc.ice_tcp_sp)] { });
+    } else {
+        dht::ThreadPool::io().run([ice = std::move(pc.ice_sp)] { });
     }
 
     // Following can create a transport that need to be negotiated (TLS).
-- 
GitLab