From 622ae14dd11c036b43e10d7c48cff4f36223440a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Blin?=
 <sebastien.blin@savoirfairelinux.com>
Date: Mon, 8 Jun 2020 10:42:30 -0400
Subject: [PATCH] jamiaccount: move checkPendingCall in another thread to avoid
 potential deadlocks

Change-Id: I5e4e54f64152c6fb6c81dfc5b1c8890878d9fdd4
---
 src/jamidht/jamiaccount.cpp | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/jamidht/jamiaccount.cpp b/src/jamidht/jamiaccount.cpp
index 44863b369f..a0babbdd42 100644
--- a/src/jamidht/jamiaccount.cpp
+++ b/src/jamidht/jamiaccount.cpp
@@ -492,9 +492,10 @@ JamiAccount::startOutgoingCall(const std::shared_ptr<SIPCall>& call, const std::
 
         auto callId = dev_call->getCallId();
         auto onNegoDone = [callId, w=weak()](bool) {
-            if (auto shared = w.lock()) {
-                shared->checkPendingCall(callId);
-            }
+            runOnMainThread([callId, w]() {
+                if (auto shared = w.lock())
+                    shared->checkPendingCall(callId);
+            });
         };
 
         std::weak_ptr<SIPCall> weak_dev_call = dev_call;
@@ -2104,9 +2105,10 @@ JamiAccount::incomingCall(dht::IceCandidates&& msg, const std::shared_ptr<dht::c
     }
     auto callId = call->getCallId();
     auto onNegoDone = [callId, w=weak()](bool) {
-        if (auto shared = w.lock()) {
-            shared->checkPendingCall(callId);
-        }
+        runOnMainThread([callId, w]() {
+            if (auto shared = w.lock())
+                shared->checkPendingCall(callId);
+        });
     };
     auto iceOptions = getIceOptions();
     iceOptions.onNegoDone = onNegoDone;
-- 
GitLab