@@ -258,6 +258,7 @@ void LLWebRTCVoiceClient::cleanupSingleton()
258
258
mNextSession ->shutdownAllConnections ();
259
259
}
260
260
cleanUp ();
261
+ stopTimer ();
261
262
sessionState::clearSessions ();
262
263
}
263
264
@@ -296,7 +297,6 @@ void LLWebRTCVoiceClient::cleanUp()
296
297
mNeighboringRegions .clear ();
297
298
sessionState::for_each (boost::bind (predShutdownSession, _1));
298
299
LL_DEBUGS (" Voice" ) << " Exiting" << LL_ENDL;
299
- stopTimer ();
300
300
}
301
301
302
302
void LLWebRTCVoiceClient::stopTimer ()
@@ -2507,15 +2507,18 @@ void LLVoiceWebRTCConnection::breakVoiceConnectionCoro(connectionPtr_t connectio
2507
2507
if (!regionp || !regionp->capabilitiesReceived ())
2508
2508
{
2509
2509
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);
2511
2513
connection->mOutstandingRequests --;
2512
2514
return ;
2513
2515
}
2514
2516
2515
2517
std::string url = regionp->getCapability (" ProvisionVoiceAccountRequest" );
2516
2518
if (url.empty ())
2517
2519
{
2518
- connection->setVoiceConnectionState (VOICE_STATE_SESSION_RETRY);
2520
+ // and go on to drop the connection here, too.
2521
+ connection->setVoiceConnectionState (VOICE_STATE_SESSION_EXIT);
2519
2522
connection->mOutstandingRequests --;
2520
2523
return ;
2521
2524
}
@@ -2529,7 +2532,7 @@ void LLVoiceWebRTCConnection::breakVoiceConnectionCoro(connectionPtr_t connectio
2529
2532
body[" voice_server_type" ] = WEBRTC_VOICE_SERVER_TYPE;
2530
2533
2531
2534
LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter (
2532
- new LLCoreHttpUtil::HttpCoroutineAdapter (" LLVoiceWebRTCAdHocConnection::breakVoiceConnection " ,
2535
+ new LLCoreHttpUtil::HttpCoroutineAdapter (" LLVoiceWebRTCAdHocConnection::breakVoiceConnectionCoro " ,
2533
2536
LLCore::HttpRequest::DEFAULT_POLICY_ID));
2534
2537
LLCore::HttpRequest::ptr_t httpRequest (new LLCore::HttpRequest);
2535
2538
LLCore::HttpOptions::ptr_t httpOpts (new LLCore::HttpOptions);
@@ -2543,8 +2546,11 @@ void LLVoiceWebRTCConnection::breakVoiceConnectionCoro(connectionPtr_t connectio
2543
2546
2544
2547
connection->mOutstandingRequests --;
2545
2548
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))
2547
2551
{
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
2548
2554
connection->setVoiceConnectionState (VOICE_STATE_SESSION_EXIT);
2549
2555
}
2550
2556
}
@@ -2829,8 +2835,8 @@ bool LLVoiceWebRTCConnection::connectionStateMachine()
2829
2835
{
2830
2836
mOutstandingRequests ++;
2831
2837
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 ()));
2834
2840
}
2835
2841
else
2836
2842
{
@@ -2843,17 +2849,18 @@ bool LLVoiceWebRTCConnection::connectionStateMachine()
2843
2849
break ;
2844
2850
2845
2851
case VOICE_STATE_SESSION_EXIT:
2852
+ setVoiceConnectionState (VOICE_STATE_WAIT_FOR_CLOSE);
2853
+ mOutstandingRequests ++;
2854
+ if (!LLWebRTCVoiceClient::isShuttingDown ())
2846
2855
{
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
+
2855
2861
case VOICE_STATE_WAIT_FOR_CLOSE:
2856
2862
break ;
2863
+
2857
2864
case VOICE_STATE_CLOSED:
2858
2865
if (!mShutDown )
2859
2866
{
@@ -2870,7 +2877,6 @@ bool LLVoiceWebRTCConnection::connectionStateMachine()
2870
2877
}
2871
2878
}
2872
2879
break ;
2873
- }
2874
2880
2875
2881
default :
2876
2882
{
@@ -3059,7 +3065,9 @@ void LLVoiceWebRTCConnection::OnDataChannelReady(llwebrtc::LLWebRTCDataInterface
3059
3065
return ;
3060
3066
}
3061
3067
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)
3063
3071
{
3064
3072
mWebRTCDataInterface = data_interface;
3065
3073
mWebRTCDataInterface ->setDataObserver (this );
0 commit comments