From cfab4e3a5b938a233429297612e54866ea5d9aee Mon Sep 17 00:00:00 2001
From: Guillaume Roguez <guillaume.roguez@savoirfairelinux.com>
Date: Wed, 2 Sep 2015 11:27:42 -0400
Subject: [PATCH] ringaccount: use manager.addTask than runOnMainThread

This was introduced by changes a8013d76b8, but it's a mistake as
we need to keep control on returned value.

Issue: #78264
Change-Id: Ibb5bf8d5e40bf4a5963170f293cb3ea15f80fdab
---
 src/ringdht/ringaccount.cpp | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/ringdht/ringaccount.cpp b/src/ringdht/ringaccount.cpp
index fbcf3bd909..91d15608c2 100644
--- a/src/ringdht/ringaccount.cpp
+++ b/src/ringdht/ringaccount.cpp
@@ -195,21 +195,21 @@ RingAccount::newOutgoingCall(const std::string& toUrl)
     setCertificateStatus(toUri, tls::TrustStore::Status::ALLOWED);
 
     std::weak_ptr<SIPCall> weak_call = call;
-    runOnMainThread([=] {
+    manager.addTask([shared_this, weak_call, ice, iceInitTimeout, toUri] {
         auto call = weak_call.lock();
 
         if (not call)
-            return;
+            return false;
 
         /* First step: wait for an initialized ICE transport for SIP channel */
         if (ice->isFailed() or std::chrono::steady_clock::now() >= iceInitTimeout) {
             RING_DBG("ice init failed (or timeout)");
             call->onFailure();
-            return;
+            return false;
         }
 
         if (not ice->isInitialized())
-            return;
+            return true; // process task again!
 
         /* Next step: sent the ICE data to peer through DHT */
         const dht::Value::Id callvid  = udist(shared_this->rand_);
@@ -254,6 +254,8 @@ RingAccount::newOutgoingCall(const std::string& toUrl)
             std::move(listenKey),
             callkey, toH
         });
+
+        return false;
     });
 
     return call;
-- 
GitLab