Skip to content
Snippets Groups Projects
Commit 3a72e386 authored by Sébastien Blin's avatar Sébastien Blin Committed by Adrien Béraud
Browse files

call: avoid multiple fallback requests

Because multiple state changes can occurs while the call is in connecting,
only start the fallback check once. Also, only fallback on parent calls, we
do not care about subcall here.

Change-Id: I1ae758d8a6f9aacc2057f736c7b4173f21add11e
Gitlab: #247
parent c1e64138
No related branches found
No related tags found
No related merge requests found
......@@ -89,24 +89,25 @@ Call::Call(Account& account, const std::string& id, Call::CallType type,
Call::ConnectionState cnx_state,
UNUSED int code) {
if (cnx_state == ConnectionState::PROGRESSING) {
if (cnx_state == ConnectionState::PROGRESSING
&& startFallback_.exchange(false)
&& not isSubcall()) {
// If the other peer lose the connectivity during the progressing
// this means that the other peer had a connectivity change we didn't
// detect for now.
// In this case, we let two secs before sending a request via the DHT
// just to bypass the CONNECTING status
std::weak_ptr<Call> callWkPtr = shared_from_this();
Manager::instance().scheduler().scheduleIn([callWkPtr]{
if (auto callShPtr = callWkPtr.lock()) {
std::weak_ptr<Call> callWkPtr = shared_from_this();
Manager::instance().scheduler().scheduleIn([callWkPtr]{
if (auto callShPtr = callWkPtr.lock()) {
if (callShPtr->getConnectionState() == Call::ConnectionState::PROGRESSING) {
JAMI_WARN("Call %s is still connecting after timeout, sending fallback request",
callShPtr->getCallId().c_str());
if (callShPtr->onNeedFallback_) callShPtr->onNeedFallback_();
JAMI_WARN("Call %s is still connecting after timeout, sending fallback request",
callShPtr->getCallId().c_str());
if (callShPtr->onNeedFallback_) callShPtr->onNeedFallback_();
}
}
}, std::chrono::seconds(2));
}, std::chrono::seconds(2));
}
checkPendingIM();
......
......@@ -32,6 +32,7 @@
#include "recordable.h"
#include "ip_utils.h"
#include <atomic>
#include <mutex>
#include <map>
#include <sstream>
......@@ -407,6 +408,7 @@ class Call : public Recordable, public std::enable_shared_from_this<Call> {
// If the call is blocked during the progressing state
OnNeedFallbackCb onNeedFallback_;
std::atomic_bool startFallback_ {true};
};
// Helpers
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment