Skip to content

Commit

Permalink
fix the bug: when trying to push same stream more than twice, to play…
Browse files Browse the repository at this point in the history
… it through http-flv will cause a core dump(#666)
  • Loading branch information
hankun committed Oct 20, 2016
1 parent d6fc289 commit 4f09bcc
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
24 changes: 24 additions & 0 deletions trunk/src/app/srs_app_http_stream.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,17 @@ SrsStreamCache::~SrsStreamCache()
srs_freep(req);
}

int SrsStreamCache::update(SrsSource* s, SrsRequest* r)
{
int ret = ERROR_SUCCESS;

srs_freep(req);
req = r->copy();
source = s;

return ret;
}

int SrsStreamCache::start()
{
return pthread->start();
Expand Down Expand Up @@ -451,6 +462,17 @@ SrsLiveStream::~SrsLiveStream()
srs_freep(req);
}

int SrsLiveStream::update(SrsSource* s, SrsRequest* r)
{
int ret = ERROR_SUCCESS;

srs_freep(req);
source = s;
req = r->copy();

return ret;
}

int SrsLiveStream::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
{
int ret = ERROR_SUCCESS;
Expand Down Expand Up @@ -836,6 +858,8 @@ int SrsHttpStreamServer::http_mount(SrsSource* s, SrsRequest* r)
srs_trace("http: mount flv stream for vhost=%s, mount=%s", sid.c_str(), mount.c_str());
} else {
entry = sflvs[sid];
entry->stream->update(s, r);
entry->cache->update(s, r);
}

if (entry->stream) {
Expand Down
2 changes: 2 additions & 0 deletions trunk/src/app/srs_app_http_stream.hpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class SrsStreamCache : public ISrsEndlessThreadHandler
public:
SrsStreamCache(SrsSource* s, SrsRequest* r);
virtual ~SrsStreamCache();
virtual int update(SrsSource* s, SrsRequest* r);
public:
virtual int start();
virtual int dump_cache(SrsConsumer* consumer, SrsRtmpJitterAlgorithm jitter);
Expand Down Expand Up @@ -227,6 +228,7 @@ class SrsLiveStream : public ISrsHttpHandler
public:
SrsLiveStream(SrsSource* s, SrsRequest* r, SrsStreamCache* c);
virtual ~SrsLiveStream();
virtual int update(SrsSource* s, SrsRequest* r);
public:
virtual int serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r);
private:
Expand Down

0 comments on commit 4f09bcc

Please sign in to comment.