From d7a83d249f7cea58f42d58ac2f3fc7de3f3430ae Mon Sep 17 00:00:00 2001
From: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com>
Date: Wed, 24 Mar 2021 16:30:41 -0400
Subject: [PATCH] sipcall: use threadpool to destroy temp media transport

IceTransport desctruction shouldn't block on the main thread.
This problem is noticable when calling refuseCall from the UI
thread and results in a blockage lasting MAX_DESTRUCTION_TIMEOUT.
Even if MAX_DESTRUCTION_TIMEOUT is not reached, a polling interval
of 500ms requires this destruction be done async.

Change-Id: Ib6f9c0cff155755de30966875ab76e7288d39405
---
 src/sip/sipcall.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/sip/sipcall.cpp b/src/sip/sipcall.cpp
index 241053f4ca..5bccabb31a 100644
--- a/src/sip/sipcall.cpp
+++ b/src/sip/sipcall.cpp
@@ -1005,7 +1005,9 @@ SIPCall::removeCall()
     Call::removeCall();
     if (mediaTransport_)
         dht::ThreadPool::io().run([ice = std::move(mediaTransport_)] {});
-    tmpMediaTransport_.reset();
+    if (tmpMediaTransport_)
+        dht::ThreadPool::io().run([ice = std::make_shared<decltype(tmpMediaTransport_)>(
+                                       std::move(tmpMediaTransport_))] {});
     setInviteSession();
     setTransport({});
 }
-- 
GitLab