From 590e9517398c4d442bcf125421353b4b338217d1 Mon Sep 17 00:00:00 2001 From: winlin Date: Mon, 5 Sep 2016 14:56:31 +0800 Subject: [PATCH] fix memory leak of source. --- trunk/src/app/srs_app_source.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/trunk/src/app/srs_app_source.cpp b/trunk/src/app/srs_app_source.cpp index 98b87c0ee..bc02eaedd 100644 --- a/trunk/src/app/srs_app_source.cpp +++ b/trunk/src/app/srs_app_source.cpp @@ -1030,7 +1030,18 @@ int SrsSource::cycle() bool SrsSource::expired() { - if (!consumers.empty() || die_at == -1) { + // unknown state? + if (die_at == -1) { + return false; + } + + // still publishing? + if (!_can_publish) { + return false; + } + + // has any consumers? + if (!consumers.empty()) { return false; } @@ -2210,7 +2221,6 @@ int SrsSource::create_consumer(SrsConnection* conn, SrsConsumer*& consumer, bool { int ret = ERROR_SUCCESS; - die_at = -1; consumer = new SrsConsumer(this, conn); consumers.push_back(consumer);