mirror of
https://github.com/ossrs/srs.git
synced 2025-02-12 19:31:53 +00:00
fix rtc over tcp crash when stop rtc publish.
@see https://github.com/ossrs/srs/issues/4220
This commit is contained in:
parent
7951bf3bd6
commit
7dd54399eb
2 changed files with 24 additions and 1 deletions
|
@ -713,10 +713,12 @@ SrsRtcTcpConn::SrsRtcTcpConn(ISrsProtocolReadWriter* skt, std::string cip, int p
|
||||||
delta_->set_io(skt_, skt_);
|
delta_->set_io(skt_, skt_);
|
||||||
session_ = NULL;
|
session_ = NULL;
|
||||||
pkt_ = new char[SRS_RTC_TCP_PACKET_MAX];
|
pkt_ = new char[SRS_RTC_TCP_PACKET_MAX];
|
||||||
|
_srs_rtc_manager->subscribe(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsRtcTcpConn::~SrsRtcTcpConn()
|
SrsRtcTcpConn::~SrsRtcTcpConn()
|
||||||
{
|
{
|
||||||
|
_srs_rtc_manager->unsubscribe(this);
|
||||||
srs_freepa(pkt_);
|
srs_freepa(pkt_);
|
||||||
srs_freep(delta_);
|
srs_freep(delta_);
|
||||||
srs_freep(skt_);
|
srs_freep(skt_);
|
||||||
|
@ -808,6 +810,23 @@ srs_error_t SrsRtcTcpConn::cycle()
|
||||||
return srs_success;
|
return srs_success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SrsRtcTcpConn::on_before_dispose(ISrsResource* c)
|
||||||
|
{
|
||||||
|
SrsRtcConnection* session = dynamic_cast<SrsRtcConnection*>(c);
|
||||||
|
if (session && session == session_) {
|
||||||
|
if (session_->tcp()->is_establelished()) {
|
||||||
|
session_->tcp()->set_state(SrsRtcNetworkStateClosed);
|
||||||
|
session_->expire();
|
||||||
|
}
|
||||||
|
|
||||||
|
session_ = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SrsRtcTcpConn::on_disposing(ISrsResource* c)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
srs_error_t SrsRtcTcpConn::do_cycle()
|
srs_error_t SrsRtcTcpConn::do_cycle()
|
||||||
{
|
{
|
||||||
srs_error_t err = srs_success;
|
srs_error_t err = srs_success;
|
||||||
|
|
|
@ -232,7 +232,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
// For WebRTC over TCP.
|
// For WebRTC over TCP.
|
||||||
class SrsRtcTcpConn : public ISrsConnection, public ISrsCoroutineHandler, public ISrsExecutorHandler
|
class SrsRtcTcpConn : public ISrsConnection, public ISrsCoroutineHandler, public ISrsExecutorHandler, public ISrsDisposingHandler
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// Because session references to this object, so we should directly use the session ptr.
|
// Because session references to this object, so we should directly use the session ptr.
|
||||||
|
@ -277,6 +277,10 @@ public:
|
||||||
// Interface ISrsCoroutineHandler
|
// Interface ISrsCoroutineHandler
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t cycle();
|
virtual srs_error_t cycle();
|
||||||
|
// Interface ISrsDisposingHandler
|
||||||
|
public:
|
||||||
|
virtual void on_before_dispose(ISrsResource* c);
|
||||||
|
virtual void on_disposing(ISrsResource* c);
|
||||||
private:
|
private:
|
||||||
virtual srs_error_t do_cycle();
|
virtual srs_error_t do_cycle();
|
||||||
srs_error_t handshake();
|
srs_error_t handshake();
|
||||||
|
|
Loading…
Reference in a new issue