Skip to content

Commit c586474

Browse files
Merge pull request #2935 from secondlife/roxie/no-double-add-data-channel-observer
Fix issue where sometimes connections would be restarted instead of closed.
2 parents 9b124b7 + c167018 commit c586474

File tree

1 file changed

+25
-17
lines changed

1 file changed

+25
-17
lines changed

indra/newview/llvoicewebrtc.cpp

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ void LLWebRTCVoiceClient::cleanupSingleton()
258258
mNextSession->shutdownAllConnections();
259259
}
260260
cleanUp();
261+
stopTimer();
261262
sessionState::clearSessions();
262263
}
263264

@@ -296,7 +297,6 @@ void LLWebRTCVoiceClient::cleanUp()
296297
mNeighboringRegions.clear();
297298
sessionState::for_each(boost::bind(predShutdownSession, _1));
298299
LL_DEBUGS("Voice") << "Exiting" << LL_ENDL;
299-
stopTimer();
300300
}
301301

302302
void LLWebRTCVoiceClient::stopTimer()
@@ -2507,15 +2507,18 @@ void LLVoiceWebRTCConnection::breakVoiceConnectionCoro(connectionPtr_t connectio
25072507
if (!regionp || !regionp->capabilitiesReceived())
25082508
{
25092509
LL_DEBUGS("Voice") << "no capabilities for voice provisioning; waiting " << LL_ENDL;
2510-
connection->setVoiceConnectionState(VOICE_STATE_SESSION_RETRY);
2510+
// fine, don't be polite and ask the janus server to break the connection.
2511+
// just fall through and drop the connection.
2512+
connection->setVoiceConnectionState(VOICE_STATE_SESSION_EXIT);
25112513
connection->mOutstandingRequests--;
25122514
return;
25132515
}
25142516

25152517
std::string url = regionp->getCapability("ProvisionVoiceAccountRequest");
25162518
if (url.empty())
25172519
{
2518-
connection->setVoiceConnectionState(VOICE_STATE_SESSION_RETRY);
2520+
// and go on to drop the connection here, too.
2521+
connection->setVoiceConnectionState(VOICE_STATE_SESSION_EXIT);
25192522
connection->mOutstandingRequests--;
25202523
return;
25212524
}
@@ -2529,7 +2532,7 @@ void LLVoiceWebRTCConnection::breakVoiceConnectionCoro(connectionPtr_t connectio
25292532
body["voice_server_type"] = WEBRTC_VOICE_SERVER_TYPE;
25302533

25312534
LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(
2532-
new LLCoreHttpUtil::HttpCoroutineAdapter("LLVoiceWebRTCAdHocConnection::breakVoiceConnection",
2535+
new LLCoreHttpUtil::HttpCoroutineAdapter("LLVoiceWebRTCAdHocConnection::breakVoiceConnectionCoro",
25332536
LLCore::HttpRequest::DEFAULT_POLICY_ID));
25342537
LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest);
25352538
LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions);
@@ -2543,8 +2546,11 @@ void LLVoiceWebRTCConnection::breakVoiceConnectionCoro(connectionPtr_t connectio
25432546

25442547
connection->mOutstandingRequests--;
25452548

2546-
if (connection->getVoiceConnectionState() == VOICE_STATE_WAIT_FOR_EXIT)
2549+
if (connection->getVoiceConnectionState() == VOICE_STATE_WAIT_FOR_EXIT ||
2550+
!(connection->getVoiceConnectionState() & VOICE_STATE_SESSION_STOPPING))
25472551
{
2552+
// drop the connection if we either somehow got set back to a running/starting state
2553+
// or we completed the call in the wait-for-exit state
25482554
connection->setVoiceConnectionState(VOICE_STATE_SESSION_EXIT);
25492555
}
25502556
}
@@ -2829,8 +2835,8 @@ bool LLVoiceWebRTCConnection::connectionStateMachine()
28292835
{
28302836
mOutstandingRequests++;
28312837
setVoiceConnectionState(VOICE_STATE_WAIT_FOR_EXIT);
2832-
LLCoros::instance().launch("LLVoiceWebRTCConnection::breakVoiceConnectionCoro",
2833-
boost::bind(&LLVoiceWebRTCConnection::breakVoiceConnectionCoro, this->shared_from_this()));
2838+
LLCoros::getInstance()->launch("LLVoiceWebRTCConnection::breakVoiceConnectionCoro",
2839+
boost::bind(&LLVoiceWebRTCConnection::breakVoiceConnectionCoro, this->shared_from_this()));
28342840
}
28352841
else
28362842
{
@@ -2843,17 +2849,18 @@ bool LLVoiceWebRTCConnection::connectionStateMachine()
28432849
break;
28442850

28452851
case VOICE_STATE_SESSION_EXIT:
2852+
setVoiceConnectionState(VOICE_STATE_WAIT_FOR_CLOSE);
2853+
mOutstandingRequests++;
2854+
if (!LLWebRTCVoiceClient::isShuttingDown())
28462855
{
2847-
setVoiceConnectionState(VOICE_STATE_WAIT_FOR_CLOSE);
2848-
mOutstandingRequests++;
2849-
if (!LLWebRTCVoiceClient::isShuttingDown())
2850-
{
2851-
mWebRTCPeerConnectionInterface->shutdownConnection();
2852-
}
2853-
// else was already posted by llwebrtc::terminate().
2854-
break;
2856+
mWebRTCPeerConnectionInterface->shutdownConnection();
2857+
}
2858+
// else was already posted by llwebrtc::terminate().
2859+
break;
2860+
28552861
case VOICE_STATE_WAIT_FOR_CLOSE:
28562862
break;
2863+
28572864
case VOICE_STATE_CLOSED:
28582865
if (!mShutDown)
28592866
{
@@ -2870,7 +2877,6 @@ bool LLVoiceWebRTCConnection::connectionStateMachine()
28702877
}
28712878
}
28722879
break;
2873-
}
28742880

28752881
default:
28762882
{
@@ -3059,7 +3065,9 @@ void LLVoiceWebRTCConnection::OnDataChannelReady(llwebrtc::LLWebRTCDataInterface
30593065
return;
30603066
}
30613067

3062-
if (data_interface)
3068+
// OnDataChannelReady may be called multiple times in a single connection attempt
3069+
// so don't double-set the observer.
3070+
if (!mWebRTCDataInterface && data_interface)
30633071
{
30643072
mWebRTCDataInterface = data_interface;
30653073
mWebRTCDataInterface->setDataObserver(this);

0 commit comments

Comments
 (0)