[fix] fix crash: ice worker still has IceWorkMsg::Type::Destroy msg which has not been processed when try to stop ice worker

This commit is contained in:
dijunkun
2024-11-27 22:15:45 +08:00
parent 1b7c8905b7
commit 21737c354a
3 changed files with 18 additions and 20 deletions

View File

@@ -162,11 +162,10 @@ int PeerConnection::Init(PeerConnectionParams params,
LOG_INFO(
"Ice failed, destroy ice agent and rereate it with TURN enabled");
IceWorkMsg msg;
msg.type = IceWorkMsg::Type::Destroy;
PushIceWorkMsg(msg);
ReleaseAllIceTransmission();
if (offer_peer_) {
IceWorkMsg msg;
msg.type = IceWorkMsg::Type::UserIdList;
msg.transmission_id = remote_transmission_id_;
msg.user_id_list = user_id_list_;
@@ -277,9 +276,7 @@ int PeerConnection::NegotiationFailed() {
user_id_, remote_user_id_, local_transmission_id_);
}
IceWorkMsg msg;
msg.type = IceWorkMsg::Type::Destroy;
PushIceWorkMsg(msg);
ReleaseAllIceTransmission();
return 0;
}
@@ -302,10 +299,16 @@ int PeerConnection::Leave(const std::string &transmission_id) {
is_ice_transmission_ready_[user_id_] = false;
leave_ = true;
IceWorkMsg msg;
msg.type = IceWorkMsg::Type::Destroy;
PushIceWorkMsg(msg);
ReleaseAllIceTransmission();
return 0;
}
int PeerConnection::ReleaseAllIceTransmission() {
for (auto &user_id_it : ice_transmission_list_) {
user_id_it.second->DestroyIceTransmission();
}
ice_transmission_list_.clear();
is_ice_transmission_ready_.clear();
return 0;
}
@@ -723,14 +726,6 @@ void PeerConnection::ProcessIceWorkMsg(const IceWorkMsg &msg) {
}
break;
}
case IceWorkMsg::Type::Destroy: {
for (auto &user_id_it : ice_transmission_list_) {
user_id_it.second->DestroyIceTransmission();
}
ice_transmission_list_.clear();
is_ice_transmission_ready_.clear();
break;
}
default: {
break;
}