From e650069a4461db97b449797be0f300ecf5cad549 Mon Sep 17 00:00:00 2001
From: andreykproductengine <andreykproductengine@lindenlab.com>
Date: Fri, 3 May 2019 14:50:54 +0300
Subject: [PATCH] SL-11058 Better delay logic

---
 indra/newview/llvoicevivox.cpp | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/indra/newview/llvoicevivox.cpp b/indra/newview/llvoicevivox.cpp
index 2584f4b9a49..ae4b0653332 100644
--- a/indra/newview/llvoicevivox.cpp
+++ b/indra/newview/llvoicevivox.cpp
@@ -658,6 +658,8 @@ void LLVivoxVoiceClient::voiceControlCoro()
     mIsCoroutineActive = true;
     LLCoros::set_consuming(true);
 
+    U32 retry = 0;
+
     while (gAgent.getTeleportState() != LLAgent::TELEPORT_NONE)
     {
         LL_DEBUGS("Voice") << "Suspending voiceControlCoro() momentarily for teleport. Tuning: " << mTuningMode << ". Relog: " << mRelogRequested << LL_ENDL;
@@ -678,6 +680,7 @@ void LLVivoxVoiceClient::voiceControlCoro()
     
             LL_DEBUGS("Voice") << "lost channel RelogRequested=" << mRelogRequested << LL_ENDL;            
             endAndDisconnectSession();
+            retry = 0;
         }
         
         // if we hit this and mRelogRequested is true, that indicates
@@ -693,10 +696,16 @@ void LLVivoxVoiceClient::voiceControlCoro()
             if (!success)
             {
                 // We failed to connect, give it a bit time before retrying.
-                llcoro::suspendUntilTimeout(5.0);
+                retry++;
+                F32 delay = llmin(5.f * (F32)retry, 60.f);
+                llcoro::suspendUntilTimeout(delay);
+                LL_INFOS("Voice") << "Voice failed to establish session after " << retry << " tries. Will attempt to reconnect." << LL_ENDL;
+            }
+            else
+            {
+                LL_INFOS("Voice") << "will attempt to reconnect to voice" << LL_ENDL;
             }
 
-            LL_INFOS("Voice") << "will attempt to reconnect to voice" << LL_ENDL;
             while (isGatewayRunning() || gAgent.getTeleportState() != LLAgent::TELEPORT_NONE)
             {
                 LL_INFOS("Voice") << "waiting for SLVoice to exit" << LL_ENDL;
-- 
GitLab