Skip to content

Commit

Permalink
fix: crash on unpublish when multiple viewers are connected
Browse files Browse the repository at this point in the history
  • Loading branch information
liumengte authored and winlinvip committed Aug 15, 2024
1 parent e323215 commit c3b6d97
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions trunk/src/app/srs_app_http_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ SrsLiveStream::SrsLiveStream(SrsRequest* r, SrsBufferCache* c)
cache = c;
req = r->copy()->as_http();
security_ = new SrsSecurity();
alive_ = false;
alive_ = 0;
}

SrsLiveStream::~SrsLiveStream()
Expand Down Expand Up @@ -634,9 +634,9 @@ srs_error_t SrsLiveStream::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage
return srs_error_wrap(err, "http hook");
}

alive_ = true;
alive_++;
err = do_serve_http(w, r);
alive_ = false;
alive_--;

http_hooks_on_stop(r);

Expand All @@ -645,7 +645,7 @@ srs_error_t SrsLiveStream::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage

bool SrsLiveStream::alive()
{
return alive_;
return alive_ > 0;
}

srs_error_t SrsLiveStream::do_serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
Expand Down
2 changes: 1 addition & 1 deletion trunk/src/app/srs_app_http_stream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ class SrsLiveStream : public ISrsHttpHandler
SrsRequest* req;
SrsBufferCache* cache;
SrsSecurity* security_;
bool alive_;
int alive_;
public:
SrsLiveStream(SrsRequest* r, SrsBufferCache* c);
virtual ~SrsLiveStream();
Expand Down

0 comments on commit c3b6d97

Please sign in to comment.