mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
RTC: Fix dup release bug
This commit is contained in:
parent
6dfeb686bf
commit
ab2d15d524
3 changed files with 13 additions and 8 deletions
|
@ -1927,6 +1927,7 @@ SrsRtcSession::SrsRtcSession(SrsRtcServer* s)
|
||||||
state_ = INIT;
|
state_ = INIT;
|
||||||
last_stun_time = 0;
|
last_stun_time = 0;
|
||||||
sessionStunTimeout = 0;
|
sessionStunTimeout = 0;
|
||||||
|
disposing_ = false;
|
||||||
|
|
||||||
blackhole = false;
|
blackhole = false;
|
||||||
blackhole_addr = NULL;
|
blackhole_addr = NULL;
|
||||||
|
|
|
@ -321,6 +321,8 @@ class SrsRtcSession
|
||||||
friend class SrsRtcDtls;
|
friend class SrsRtcDtls;
|
||||||
friend class SrsRtcPlayer;
|
friend class SrsRtcPlayer;
|
||||||
friend class SrsRtcPublisher;
|
friend class SrsRtcPublisher;
|
||||||
|
public:
|
||||||
|
bool disposing_;
|
||||||
private:
|
private:
|
||||||
SrsRtcServer* server_;
|
SrsRtcServer* server_;
|
||||||
SrsRtcSessionStateType state_;
|
SrsRtcSessionStateType state_;
|
||||||
|
|
|
@ -411,6 +411,11 @@ srs_error_t SrsRtcServer::setup_session2(SrsRtcSession* session, SrsRequest* req
|
||||||
|
|
||||||
void SrsRtcServer::destroy(SrsRtcSession* session)
|
void SrsRtcServer::destroy(SrsRtcSession* session)
|
||||||
{
|
{
|
||||||
|
if (session->disposing_) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
session->disposing_ = true;
|
||||||
|
|
||||||
std::map<std::string, SrsRtcSession*>::iterator it;
|
std::map<std::string, SrsRtcSession*>::iterator it;
|
||||||
|
|
||||||
if ((it = map_username_session.find(session->username())) != map_username_session.end()) {
|
if ((it = map_username_session.find(session->username())) != map_username_session.end()) {
|
||||||
|
@ -421,9 +426,7 @@ void SrsRtcServer::destroy(SrsRtcSession* session)
|
||||||
map_id_session.erase(it);
|
map_id_session.erase(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (::find(zombies_.begin(), zombies_.end(), session) == zombies_.end()) {
|
zombies_.push_back(session);
|
||||||
zombies_.push_back(session);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SrsRtcServer::insert_into_id_sessions(const string& peer_id, SrsRtcSession* session)
|
bool SrsRtcServer::insert_into_id_sessions(const string& peer_id, SrsRtcSession* session)
|
||||||
|
@ -446,18 +449,17 @@ void SrsRtcServer::check_and_clean_timeout_session()
|
||||||
// Now, we got the RTC session to cleanup, switch to its context
|
// Now, we got the RTC session to cleanup, switch to its context
|
||||||
// to make all logs write to the "correct" pid+cid.
|
// to make all logs write to the "correct" pid+cid.
|
||||||
session->switch_to_context();
|
session->switch_to_context();
|
||||||
|
|
||||||
srs_trace("rtc session=%s, STUN timeout", session->id().c_str());
|
srs_trace("rtc session=%s, STUN timeout", session->id().c_str());
|
||||||
|
|
||||||
|
session->disposing_ = true;
|
||||||
|
zombies_.push_back(session);
|
||||||
|
|
||||||
iter = map_username_session.erase(iter);
|
iter = map_username_session.erase(iter);
|
||||||
map_id_session.erase(session->peer_id());
|
map_id_session.erase(session->peer_id());
|
||||||
|
|
||||||
if (handler) {
|
if (handler) {
|
||||||
handler->on_timeout(session);
|
handler->on_timeout(session);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (::find(zombies_.begin(), zombies_.end(), session) == zombies_.end()) {
|
|
||||||
zombies_.push_back(session);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue