Closed winlinvip closed 2 months ago
for (;;) { if (!cache->alive() && !stream->alive()) { break; } // A circle reference.
Note: It also introduces a circular reference in the object relationships, the stream reference to itself when unmount:
I don't understand the circle reference in http_unmount
. And use a async work to delay the SrsLiveStream
destroy after http_unmount
finished.
The SrsLiveStream
created in http_mount
and destroyed in http_unmount
, it's reasonable, not circle reference here, I believe.
Is the circle reference means SrsLiveStream
destroyed in http_unmount
, but the SrsHttpConn
continue running in SrsLiveStream::serve_http
? I think #4166 also fixed it.
SrsLiveStream::serve_http -> SrsLiveConsumer::~SrsLiveConsumer -> SrsEdgeIngester::stop -> SrsLiveSource::on_unpublish -> SrsHttpStreamServer::http_unmount -> SrsLiveStream::alive
There are no cycle reference of SrsLiveStream
now, SrsLiveConsumer
only destroyed when out of SrsLiveStream::serve_http
, and the viewers_.erase(SrsHttpConn)
run at the end of SrsLiveStream::serve_http
, SrsLiveStream::alive
do well in this case.
Co-authored-by: Jacob Su suzp1984@gmail.com