From 4f09bcce9f1b10a95dd2e57aaad03038956d7a4a Mon Sep 17 00:00:00 2001 From: hankun Date: Fri, 14 Oct 2016 16:05:19 +0800 Subject: [PATCH] fix the bug: when trying to push same stream more than twice, to play it through http-flv will cause a core dump(#666) --- trunk/src/app/srs_app_http_stream.cpp | 24 ++++++++++++++++++++++++ trunk/src/app/srs_app_http_stream.hpp | 2 ++ 2 files changed, 26 insertions(+) mode change 100644 => 100755 trunk/src/app/srs_app_http_stream.cpp mode change 100644 => 100755 trunk/src/app/srs_app_http_stream.hpp diff --git a/trunk/src/app/srs_app_http_stream.cpp b/trunk/src/app/srs_app_http_stream.cpp old mode 100644 new mode 100755 index 7f40d74c02..0cd864a970 --- a/trunk/src/app/srs_app_http_stream.cpp +++ b/trunk/src/app/srs_app_http_stream.cpp @@ -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(); @@ -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; @@ -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) { diff --git a/trunk/src/app/srs_app_http_stream.hpp b/trunk/src/app/srs_app_http_stream.hpp old mode 100644 new mode 100755 index 1ea95ebe9a..83b90bcf56 --- a/trunk/src/app/srs_app_http_stream.hpp +++ b/trunk/src/app/srs_app_http_stream.hpp @@ -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); @@ -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: