From c1e641387e919b5ff4ed391bc972e34a444f4fbd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Blin?=
 <sebastien.blin@savoirfairelinux.com>
Date: Thu, 25 Jun 2020 16:28:10 -0400
Subject: [PATCH] jamiaccount: re-add searching/connecting timeouts

Because we removed the eventloop to check pending calls, timeout are not checked
and only done on successfully negotiated ICE. We should re-add timeouts to avoid
any lock during the Searching or the Connecting state.

Change-Id: Id4f9a4869c171a5c3f316b76e9ecede1bc76ed97
Gitlab: #244
---
 src/jamidht/jamiaccount.cpp | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/jamidht/jamiaccount.cpp b/src/jamidht/jamiaccount.cpp
index 29220294cb..f006cfecb2 100644
--- a/src/jamidht/jamiaccount.cpp
+++ b/src/jamidht/jamiaccount.cpp
@@ -610,6 +610,11 @@ JamiAccount::startOutgoingCall(const std::shared_ptr<SIPCall>& call, const std::
                 peer_account,
                 tls::CertificateStore::instance().getCertificate(toUri)
             });
+
+            Manager::instance().scheduleTask([w, callId=call->getCallId()]() {
+                if (auto shared = w.lock())
+                    shared->checkPendingCall(callId);
+            }, std::chrono::steady_clock::now() + ICE_NEGOTIATION_TIMEOUT);
             return false;
         });
     };
@@ -2230,6 +2235,11 @@ JamiAccount::replyToIncomingIceMsg(const std::shared_ptr<SIPCall>& call,
                     /*.from = */ peer_ice_msg.from,
                     /*.from_account = */ from_id,
                     /*.from_cert = */ from_cert});
+
+    Manager::instance().scheduleTask([w=weak(), callId=call->getCallId()]() {
+        if (auto shared = w.lock())
+            shared->checkPendingCall(callId);
+    }, std::chrono::steady_clock::now() + ICE_NEGOTIATION_TIMEOUT);
 }
 
 void
-- 
GitLab