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;
|
||||
last_stun_time = 0;
|
||||
sessionStunTimeout = 0;
|
||||
disposing_ = false;
|
||||
|
||||
blackhole = false;
|
||||
blackhole_addr = NULL;
|
||||
|
|
|
@ -321,6 +321,8 @@ class SrsRtcSession
|
|||
friend class SrsRtcDtls;
|
||||
friend class SrsRtcPlayer;
|
||||
friend class SrsRtcPublisher;
|
||||
public:
|
||||
bool disposing_;
|
||||
private:
|
||||
SrsRtcServer* server_;
|
||||
SrsRtcSessionStateType state_;
|
||||
|
|
|
@ -411,6 +411,11 @@ srs_error_t SrsRtcServer::setup_session2(SrsRtcSession* session, SrsRequest* req
|
|||
|
||||
void SrsRtcServer::destroy(SrsRtcSession* session)
|
||||
{
|
||||
if (session->disposing_) {
|
||||
return;
|
||||
}
|
||||
session->disposing_ = true;
|
||||
|
||||
std::map<std::string, SrsRtcSession*>::iterator it;
|
||||
|
||||
if ((it = map_username_session.find(session->username())) != map_username_session.end()) {
|
||||
|
@ -421,10 +426,8 @@ void SrsRtcServer::destroy(SrsRtcSession* session)
|
|||
map_id_session.erase(it);
|
||||
}
|
||||
|
||||
if (::find(zombies_.begin(), zombies_.end(), session) == zombies_.end()) {
|
||||
zombies_.push_back(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
|
||||
// to make all logs write to the "correct" pid+cid.
|
||||
session->switch_to_context();
|
||||
|
||||
srs_trace("rtc session=%s, STUN timeout", session->id().c_str());
|
||||
|
||||
session->disposing_ = true;
|
||||
zombies_.push_back(session);
|
||||
|
||||
iter = map_username_session.erase(iter);
|
||||
map_id_session.erase(session->peer_id());
|
||||
|
||||
if (handler) {
|
||||
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