diff --git a/src/call.cpp b/src/call.cpp index a945ddf666cda627be23665babd05a06c35a83ec..f4a23665b3faff9e91a48f733eb6c4d76b4a8e5d 100644 --- a/src/call.cpp +++ b/src/call.cpp @@ -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(); diff --git a/src/call.h b/src/call.h index 3d74493fbc8e904937ed8e34d43b16be7715427a..eba94d615534f201ed07539acf17b842291e62b3 100644 --- a/src/call.h +++ b/src/call.h @@ -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