Skip to content

Commit 12ea8e4

Browse files
committed
Fix issue where some connections were restarting instead of closing.
There was an issue where, when a connection close is requested, a new connection is created. Specifically, if the caps are not yet available, a new connection would start.
1 parent ed6ebed commit 12ea8e4

File tree

2 files changed

+21
-17
lines changed

2 files changed

+21
-17
lines changed

indra/newview/llvoicewebrtc.cpp

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2478,7 +2478,7 @@ void LLVoiceWebRTCConnection::sendData(const std::string &data)
24782478

24792479
// Tell the simulator that we're shutting down a voice connection.
24802480
// The simulator will pass this on to the Secondlife WebRTC server.
2481-
void LLVoiceWebRTCConnection::breakVoiceConnectionCoro(connectionPtr_t connection)
2481+
void LLVoiceWebRTCConnection::breakVoiceConnection(connectionPtr_t connection)
24822482
{
24832483
LL_PROFILE_ZONE_SCOPED_CATEGORY_VOICE;
24842484

@@ -2493,15 +2493,18 @@ void LLVoiceWebRTCConnection::breakVoiceConnectionCoro(connectionPtr_t connectio
24932493
if (!regionp || !regionp->capabilitiesReceived())
24942494
{
24952495
LL_DEBUGS("Voice") << "no capabilities for voice provisioning; waiting " << LL_ENDL;
2496-
connection->setVoiceConnectionState(VOICE_STATE_SESSION_RETRY);
2496+
// fine, don't be polite and ask the janus server to break the connection.
2497+
// just fall through and drop the connection.
2498+
connection->setVoiceConnectionState(VOICE_STATE_SESSION_EXIT);
24972499
connection->mOutstandingRequests--;
24982500
return;
24992501
}
25002502

25012503
std::string url = regionp->getCapability("ProvisionVoiceAccountRequest");
25022504
if (url.empty())
25032505
{
2504-
connection->setVoiceConnectionState(VOICE_STATE_SESSION_RETRY);
2506+
// and go on to drop the connection here, too.
2507+
connection->setVoiceConnectionState(VOICE_STATE_SESSION_EXIT);
25052508
connection->mOutstandingRequests--;
25062509
return;
25072510
}
@@ -2529,8 +2532,11 @@ void LLVoiceWebRTCConnection::breakVoiceConnectionCoro(connectionPtr_t connectio
25292532

25302533
connection->mOutstandingRequests--;
25312534

2532-
if (connection->getVoiceConnectionState() == VOICE_STATE_WAIT_FOR_EXIT)
2535+
if (connection->getVoiceConnectionState() == VOICE_STATE_WAIT_FOR_EXIT ||
2536+
!(connection->getVoiceConnectionState() & VOICE_STATE_SESSION_STOPPING))
25332537
{
2538+
// drop the connection if we either somehow got set back to a running/starting state
2539+
// or we completed the call in the wait-for-exit state
25342540
connection->setVoiceConnectionState(VOICE_STATE_SESSION_EXIT);
25352541
}
25362542
}
@@ -2814,9 +2820,7 @@ bool LLVoiceWebRTCConnection::connectionStateMachine()
28142820
if (!LLWebRTCVoiceClient::isShuttingDown())
28152821
{
28162822
mOutstandingRequests++;
2817-
setVoiceConnectionState(VOICE_STATE_WAIT_FOR_EXIT);
2818-
LLCoros::instance().launch("LLVoiceWebRTCConnection::breakVoiceConnectionCoro",
2819-
boost::bind(&LLVoiceWebRTCConnection::breakVoiceConnectionCoro, this->shared_from_this()));
2823+
breakVoiceConnection(this->shared_from_this());
28202824
}
28212825
else
28222826
{
@@ -2829,17 +2833,18 @@ bool LLVoiceWebRTCConnection::connectionStateMachine()
28292833
break;
28302834

28312835
case VOICE_STATE_SESSION_EXIT:
2836+
setVoiceConnectionState(VOICE_STATE_WAIT_FOR_CLOSE);
2837+
mOutstandingRequests++;
2838+
if (!LLWebRTCVoiceClient::isShuttingDown())
28322839
{
2833-
setVoiceConnectionState(VOICE_STATE_WAIT_FOR_CLOSE);
2834-
mOutstandingRequests++;
2835-
if (!LLWebRTCVoiceClient::isShuttingDown())
2836-
{
2837-
mWebRTCPeerConnectionInterface->shutdownConnection();
2838-
}
2839-
// else was already posted by llwebrtc::terminate().
2840-
break;
2840+
mWebRTCPeerConnectionInterface->shutdownConnection();
2841+
}
2842+
// else was already posted by llwebrtc::terminate().
2843+
break;
2844+
28412845
case VOICE_STATE_WAIT_FOR_CLOSE:
28422846
break;
2847+
28432848
case VOICE_STATE_CLOSED:
28442849
if (!mShutDown)
28452850
{
@@ -2856,7 +2861,6 @@ bool LLVoiceWebRTCConnection::connectionStateMachine()
28562861
}
28572862
}
28582863
break;
2859-
}
28602864

28612865
default:
28622866
{

indra/newview/llvoicewebrtc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ class LLVoiceWebRTCConnection :
691691
virtual void requestVoiceConnection() = 0;
692692
static void requestVoiceConnectionCoro(connectionPtr_t connection) { connection->requestVoiceConnection(); }
693693

694-
static void breakVoiceConnectionCoro(connectionPtr_t connection);
694+
static void breakVoiceConnection(connectionPtr_t connection);
695695

696696
LLVoiceClientStatusObserver::EStatusType mCurrentStatus;
697697

0 commit comments

Comments
 (0)