More session shutdown cleanup

master
Roxie Linden 2024-05-19 02:30:45 -07:00
parent 2b275d43fb
commit ddbd1ab47e
6 changed files with 34 additions and 9 deletions

View File

@ -280,9 +280,15 @@ void LLWebRTCImpl::terminate()
{
connection->terminate();
}
mPeerConnections.clear();
// connection->terminate() above spawns a number of Signaling thread calls to
// shut down the connection. The following Blocking Call will wait
// until they're done before it's executed, allowing time to clean up.
mSignalingThread->BlockingCall([this]() { mPeerConnectionFactory = nullptr; });
mPeerConnections.clear();
mWorkerThread->BlockingCall(
[this]()
{
@ -652,7 +658,6 @@ LLWebRTCPeerConnectionImpl::LLWebRTCPeerConnectionImpl() :
LLWebRTCPeerConnectionImpl::~LLWebRTCPeerConnectionImpl()
{
terminate();
mSignalingObserverList.clear();
mDataObserverList.clear();
}

View File

@ -94,6 +94,7 @@ LLFloaterIMSession::LLFloaterIMSession(const LLUUID& session_id)
mEnableCallbackRegistrar.add("Avatar.EnableGearItem", boost::bind(&LLFloaterIMSession::enableGearMenuItem, this, _2));
mCommitCallbackRegistrar.add("Avatar.GearDoToSelected", boost::bind(&LLFloaterIMSession::GearDoToSelected, this, _2));
mEnableCallbackRegistrar.add("Avatar.CheckGearItem", boost::bind(&LLFloaterIMSession::checkGearMenuItem, this, _2));
mVoiceChannelChanged = LLVoiceChannel::setCurrentVoiceChannelChangedCallback(boost::bind(&LLFloaterIMSession::onVoiceChannelChanged, this, _1));
setDocked(true);
}
@ -292,6 +293,8 @@ LLFloaterIMSession::~LLFloaterIMSession()
}
LLTransientFloaterMgr::getInstance()->removeControlView(LLTransientFloaterMgr::IM, this);
mVoiceChannelChanged.disconnect();
}
@ -521,6 +524,14 @@ void LLFloaterIMSession::sendParticipantsAddedNotification(const uuid_vec_t& uui
sendMsg(getString(uuids.size() > 1 ? "multiple_participants_added" : "participant_added", args));
}
void LLFloaterIMSession::onVoiceChannelChanged(const LLUUID &session_id)
{
if (session_id == mSessionID)
{
boundVoiceChannel();
}
}
void LLFloaterIMSession::boundVoiceChannel()
{
LLVoiceChannel* voice_channel = LLIMModel::getInstance()->getVoiceChannel(mSessionID);

View File

@ -161,6 +161,8 @@ private:
void onCallButtonClicked();
void onVoiceChannelChanged(const LLUUID &session_id);
void boundVoiceChannel();
// Add the "User is typing..." indicator.
@ -195,6 +197,9 @@ private:
uuid_vec_t mInvitedParticipants;
uuid_vec_t mPendingParticipants;
// notification when the voice channel is swapped out from beneath us.
boost::signals2::connection mVoiceChannelChanged;
// connection to voice channel state change signal
boost::signals2::connection mVoiceChannelStateChangeConnection;

View File

@ -789,10 +789,15 @@ LLIMModel::LLIMSession::LLIMSession(const LLUUID& session_id,
void LLIMModel::LLIMSession::initVoiceChannel(const LLSD& voiceChannelInfo)
{
mVoiceChannelStateChangeConnection.disconnect();
if (mVoiceChannel)
{
if (mVoiceChannel->isThisVoiceChannel(voiceChannelInfo))
{
return;
}
mVoiceChannelStateChangeConnection.disconnect();
mVoiceChannel->deactivate();
delete mVoiceChannel;

View File

@ -93,6 +93,8 @@ public:
void setCallDirection(EDirection direction) {mCallDirection = direction;}
EDirection getCallDirection() {return mCallDirection;}
bool isThisVoiceChannel(const LLSD &voiceChannelInfo) { return LLVoiceClient::getInstance()->compareChannels(mChannelInfo, voiceChannelInfo); }
static LLVoiceChannel* getChannelByID(const LLUUID& session_id);
static LLVoiceChannel* getCurrentVoiceChannel();
@ -115,7 +117,7 @@ public:
EState mState;
std::string mSessionName;
LLSD mNotifyArgs;
LLSD mChannelInfo;
LLSD mChannelInfo;
// true if call was ended by agent
bool mCallEndedByAgent;
bool mIgnoreNextSessionLeave;

View File

@ -2471,7 +2471,6 @@ void LLVoiceWebRTCConnection::breakVoiceConnectionCoro()
httpOpts->setWantHeaders(true);
mOutstandingRequests++;
setVoiceConnectionState(VOICE_STATE_WAIT_FOR_EXIT);
// tell the server to shut down the connection as a courtesy.
// shutdownConnection will drop the WebRTC connection which will
@ -2479,10 +2478,7 @@ void LLVoiceWebRTCConnection::breakVoiceConnectionCoro()
LLSD result = httpAdapter->postAndSuspend(httpRequest, url, body, httpOpts);
mOutstandingRequests--;
if (!LLWebRTCVoiceClient::isShuttingDown())
{
setVoiceConnectionState(VOICE_STATE_SESSION_EXIT);
}
setVoiceConnectionState(VOICE_STATE_SESSION_EXIT);
}
// Tell the simulator to tell the Secondlife WebRTC server that we want a voice
@ -2745,6 +2741,7 @@ bool LLVoiceWebRTCConnection::connectionStateMachine()
break;
case VOICE_STATE_DISCONNECT:
setVoiceConnectionState(VOICE_STATE_WAIT_FOR_EXIT);
LLCoros::instance().launch("LLVoiceWebRTCConnection::breakVoiceConnectionCoro",
boost::bind(&LLVoiceWebRTCConnection::breakVoiceConnectionCoro, this));
break;