mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
HTTP-FLV: Notify connection to expire when unpublishing. v6.0.152 (#4164)
When stopping the stream, it will wait for the HTTP Streaming to exit. If the HTTP Streaming goroutine hangs, it will not exit automatically. ```cpp void SrsHttpStreamServer::http_unmount(SrsRequest* r) { SrsUniquePtr<SrsLiveStream> stream(entry->stream); if (stream->entry) stream->entry->enabled = false; srs_usleep(...); // Wait for about 120s. mux.unhandle(entry->mount, stream.get()); // Free stream. } srs_error_t SrsLiveStream::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) { err = do_serve_http(w, r); // If stuck in here for 120s+ alive_viewers_--; // Crash at here, because stream has been deleted. ``` We should notify http stream connection to interrupt(expire): ```cpp void SrsHttpStreamServer::http_unmount(SrsRequest* r) { SrsUniquePtr<SrsLiveStream> stream(entry->stream); if (stream->entry) stream->entry->enabled = false; stream->expire(); // Notify http stream to interrupt. ``` Note that we should notify all viewers pulling stream from this http stream. Note that we have tried to fix this issue, but only try to wait for all viewers to quit, without interrupting the viewers, see https://github.com/ossrs/srs/pull/4144 --------- Co-authored-by: Jacob Su <suzp1984@gmail.com>
This commit is contained in:
parent
da5683e478
commit
d27e530f84
5 changed files with 34 additions and 10 deletions
|
@ -11,6 +11,8 @@
|
|||
#include <srs_app_security.hpp>
|
||||
#include <srs_app_http_conn.hpp>
|
||||
|
||||
#include <vector>
|
||||
|
||||
class SrsAacTransmuxer;
|
||||
class SrsMp3Transmuxer;
|
||||
class SrsFlvTransmuxer;
|
||||
|
@ -176,7 +178,7 @@ public:
|
|||
|
||||
// HTTP Live Streaming, to transmux RTMP to HTTP FLV or other format.
|
||||
// TODO: FIXME: Rename to SrsHttpLive
|
||||
class SrsLiveStream : public ISrsHttpHandler
|
||||
class SrsLiveStream : public ISrsHttpHandler, public ISrsExpire
|
||||
{
|
||||
private:
|
||||
SrsRequest* req;
|
||||
|
@ -185,7 +187,7 @@ private:
|
|||
// For multiple viewers, which means there will more than one alive viewers for a live stream, so we must
|
||||
// use an int value to represent if there is any viewer is alive. We should never do cleanup unless all
|
||||
// viewers closed the connection.
|
||||
int alive_viewers_;
|
||||
std::vector<ISrsExpire*> viewers_;
|
||||
public:
|
||||
SrsLiveStream(SrsRequest* r, SrsBufferCache* c);
|
||||
virtual ~SrsLiveStream();
|
||||
|
@ -193,6 +195,9 @@ public:
|
|||
public:
|
||||
virtual srs_error_t serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r);
|
||||
virtual bool alive();
|
||||
// Interface ISrsExpire
|
||||
public:
|
||||
virtual void expire();
|
||||
private:
|
||||
virtual srs_error_t do_serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r);
|
||||
virtual srs_error_t http_hooks_on_play(ISrsHttpMessage* r);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue