mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-26 12:15:34 +08:00
[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:
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "log.h"
|
||||
|
||||
#define SAVE_IO_STREAM
|
||||
// #define SAVE_IO_STREAM
|
||||
|
||||
IceAgent::IceAgent(bool offer_peer, bool use_trickle_ice, bool use_reliable_ice,
|
||||
bool enable_turn, bool force_turn, std::string &stun_ip,
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -68,8 +68,7 @@ struct IceWorkMsg {
|
||||
UserLeaveTransmission,
|
||||
Offer,
|
||||
Answer,
|
||||
NewCandidate,
|
||||
Destroy
|
||||
NewCandidate
|
||||
};
|
||||
|
||||
Type type;
|
||||
@@ -97,6 +96,8 @@ class PeerConnection {
|
||||
|
||||
int Leave(const std::string &transmission_id);
|
||||
|
||||
int ReleaseAllIceTransmission();
|
||||
|
||||
int Destroy();
|
||||
|
||||
SignalStatus GetSignalStatus();
|
||||
@@ -201,7 +202,9 @@ class PeerConnection {
|
||||
std::atomic<bool> ice_worker_running_{true};
|
||||
std::queue<IceWorkMsg> ice_work_msg_queue_;
|
||||
std::condition_variable ice_work_cv_;
|
||||
std::condition_variable empty_notify_cv_;
|
||||
std::mutex ice_work_mutex_;
|
||||
std::mutex empty_notify_mutex_;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user