fix the bug: when trying to push same stream more than twice, to play it through…
… http-flv will cause a core dump(#666)
正在显示
2 个修改的文件
包含
26 行增加
和
0 行删除
trunk/src/app/srs_app_http_stream.cpp
100644 → 100755
@@ -78,6 +78,17 @@ SrsStreamCache::~SrsStreamCache() | @@ -78,6 +78,17 @@ SrsStreamCache::~SrsStreamCache() | ||
78 | srs_freep(req); | 78 | srs_freep(req); |
79 | } | 79 | } |
80 | 80 | ||
81 | +int SrsStreamCache::update(SrsSource* s, SrsRequest* r) | ||
82 | +{ | ||
83 | + int ret = ERROR_SUCCESS; | ||
84 | + | ||
85 | + srs_freep(req); | ||
86 | + req = r->copy(); | ||
87 | + source = s; | ||
88 | + | ||
89 | + return ret; | ||
90 | +} | ||
91 | + | ||
81 | int SrsStreamCache::start() | 92 | int SrsStreamCache::start() |
82 | { | 93 | { |
83 | return pthread->start(); | 94 | return pthread->start(); |
@@ -451,6 +462,17 @@ SrsLiveStream::~SrsLiveStream() | @@ -451,6 +462,17 @@ SrsLiveStream::~SrsLiveStream() | ||
451 | srs_freep(req); | 462 | srs_freep(req); |
452 | } | 463 | } |
453 | 464 | ||
465 | +int SrsLiveStream::update(SrsSource* s, SrsRequest* r) | ||
466 | +{ | ||
467 | + int ret = ERROR_SUCCESS; | ||
468 | + | ||
469 | + srs_freep(req); | ||
470 | + source = s; | ||
471 | + req = r->copy(); | ||
472 | + | ||
473 | + return ret; | ||
474 | +} | ||
475 | + | ||
454 | int SrsLiveStream::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | 476 | int SrsLiveStream::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) |
455 | { | 477 | { |
456 | int ret = ERROR_SUCCESS; | 478 | int ret = ERROR_SUCCESS; |
@@ -836,6 +858,8 @@ int SrsHttpStreamServer::http_mount(SrsSource* s, SrsRequest* r) | @@ -836,6 +858,8 @@ int SrsHttpStreamServer::http_mount(SrsSource* s, SrsRequest* r) | ||
836 | srs_trace("http: mount flv stream for vhost=%s, mount=%s", sid.c_str(), mount.c_str()); | 858 | srs_trace("http: mount flv stream for vhost=%s, mount=%s", sid.c_str(), mount.c_str()); |
837 | } else { | 859 | } else { |
838 | entry = sflvs[sid]; | 860 | entry = sflvs[sid]; |
861 | + entry->stream->update(s, r); | ||
862 | + entry->cache->update(s, r); | ||
839 | } | 863 | } |
840 | 864 | ||
841 | if (entry->stream) { | 865 | if (entry->stream) { |
trunk/src/app/srs_app_http_stream.hpp
100644 → 100755
@@ -51,6 +51,7 @@ private: | @@ -51,6 +51,7 @@ private: | ||
51 | public: | 51 | public: |
52 | SrsStreamCache(SrsSource* s, SrsRequest* r); | 52 | SrsStreamCache(SrsSource* s, SrsRequest* r); |
53 | virtual ~SrsStreamCache(); | 53 | virtual ~SrsStreamCache(); |
54 | + virtual int update(SrsSource* s, SrsRequest* r); | ||
54 | public: | 55 | public: |
55 | virtual int start(); | 56 | virtual int start(); |
56 | virtual int dump_cache(SrsConsumer* consumer, SrsRtmpJitterAlgorithm jitter); | 57 | virtual int dump_cache(SrsConsumer* consumer, SrsRtmpJitterAlgorithm jitter); |
@@ -227,6 +228,7 @@ private: | @@ -227,6 +228,7 @@ private: | ||
227 | public: | 228 | public: |
228 | SrsLiveStream(SrsSource* s, SrsRequest* r, SrsStreamCache* c); | 229 | SrsLiveStream(SrsSource* s, SrsRequest* r, SrsStreamCache* c); |
229 | virtual ~SrsLiveStream(); | 230 | virtual ~SrsLiveStream(); |
231 | + virtual int update(SrsSource* s, SrsRequest* r); | ||
230 | public: | 232 | public: |
231 | virtual int serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r); | 233 | virtual int serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r); |
232 | private: | 234 | private: |
-
请 注册 或 登录 后发表评论