From 4e42b9c6286bd8483d8736803506ab5ec0b2a788 Mon Sep 17 00:00:00 2001 From: winlin Date: Tue, 2 Jun 2015 12:56:04 +0800 Subject: [PATCH 1/2] copy the request for hls. --- trunk/src/app/srs_app_hls.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/trunk/src/app/srs_app_hls.cpp b/trunk/src/app/srs_app_hls.cpp index 6ac0c2b5f..d6cdbe42c 100644 --- a/trunk/src/app/srs_app_hls.cpp +++ b/trunk/src/app/srs_app_hls.cpp @@ -1117,6 +1117,7 @@ int SrsHlsCache::reap_segment(string log_desc, SrsHlsMuxer* muxer, int64_t segme SrsHls::SrsHls() { + _req = NULL; source = NULL; handler = NULL; @@ -1137,6 +1138,7 @@ SrsHls::SrsHls() SrsHls::~SrsHls() { + srs_freep(_req); srs_freep(codec); srs_freep(sample); srs_freep(jitter); @@ -1205,7 +1207,8 @@ int SrsHls::on_publish(SrsRequest* req) { int ret = ERROR_SUCCESS; - _req = req; + srs_freep(_req); + _req = req->copy(); // update the hls time, for hls_dispose. last_update_time = srs_get_system_time_ms(); From af9efe921394cdbe0ddcc0cf4728b6fff7c2cd45 Mon Sep 17 00:00:00 2001 From: winlin Date: Wed, 3 Jun 2015 10:13:46 +0800 Subject: [PATCH 2/2] disable the hls_dispose by default to 0, for p2p system should never cleanup for timeshift hls. --- trunk/conf/full.conf | 5 +++-- trunk/src/app/srs_app_config.cpp | 2 +- trunk/src/app/srs_app_hls.cpp | 8 ++++++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/trunk/conf/full.conf b/trunk/conf/full.conf index cab0cd054..a12061bbc 100644 --- a/trunk/conf/full.conf +++ b/trunk/conf/full.conf @@ -624,8 +624,9 @@ vhost with-hls.srs.com { # the timeout in seconds to dispose the hls, # dispose is to remove all hls files, m3u8 and ts files. # when timeout or server terminate, dispose hls. - # default: 300 - hls_dispose 300; + # @remark 0 to disable dispose. + # default: 0 + hls_dispose 0; # the max size to notify hls, # to read max bytes from ts of specified cdn network, # @remark only used when on_hls_notify is config. diff --git a/trunk/src/app/srs_app_config.cpp b/trunk/src/app/srs_app_config.cpp index 056f1efdd..082f2efda 100644 --- a/trunk/src/app/srs_app_config.cpp +++ b/trunk/src/app/srs_app_config.cpp @@ -3566,7 +3566,7 @@ int SrsConfig::get_hls_dispose(string vhost) { SrsConfDirective* conf = get_hls(vhost); - int DEFAULT = 300; + int DEFAULT = 0; if (!conf) { return DEFAULT; diff --git a/trunk/src/app/srs_app_hls.cpp b/trunk/src/app/srs_app_hls.cpp index d6cdbe42c..24750ec09 100644 --- a/trunk/src/app/srs_app_hls.cpp +++ b/trunk/src/app/srs_app_hls.cpp @@ -1155,6 +1155,14 @@ void SrsHls::dispose() on_unpublish(); } + // only dispose hls when positive. + if (_req) { + int hls_dispose = _srs_config->get_hls_dispose(_req->vhost); + if (hls_dispose <= 0) { + return; + } + } + muxer->dispose(); }