From a994191ddccf409a737b4f99a5fabac22f1157f2 Mon Sep 17 00:00:00 2001 From: winlin Date: Mon, 14 Sep 2015 15:10:34 +0800 Subject: [PATCH] for #474, always release publish for source. --- README.md | 2 ++ trunk/src/app/srs_app_rtmp_conn.cpp | 10 ++++++++-- trunk/src/app/srs_app_source.cpp | 1 + trunk/src/app/srs_app_thread.cpp | 2 ++ 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ae0c46e3a..b00951bfe 100755 --- a/README.md +++ b/README.md @@ -343,6 +343,7 @@ Remark: ## History +* v2.0, 2015-09-14, for [#474][bug #474] always release publish for source. * v2.0, 2015-09-14, for [#458][bug #458] http hooks use source thread cid. 2.0.188 * v2.0, 2015-09-14, for [#475][bug #475] fix http hooks crash for st context switch. 2.0.187 * v2.0, 2015-09-09, support reload utc_time. 2.0.186 @@ -1026,6 +1027,7 @@ Winlin [bug #133]: https://github.com/simple-rtmp-server/srs/issues/133 [bug #92]: https://github.com/simple-rtmp-server/srs/issues/92 [bug #380]: https://github.com/simple-rtmp-server/srs/issues/380 +[bug #474]: https://github.com/simple-rtmp-server/srs/issues/474 [bug #475]: https://github.com/simple-rtmp-server/srs/issues/475 [bug #458]: https://github.com/simple-rtmp-server/srs/issues/458 [bug #454]: https://github.com/simple-rtmp-server/srs/issues/454 diff --git a/trunk/src/app/srs_app_rtmp_conn.cpp b/trunk/src/app/srs_app_rtmp_conn.cpp index 51fb46d84..8a8321034 100755 --- a/trunk/src/app/srs_app_rtmp_conn.cpp +++ b/trunk/src/app/srs_app_rtmp_conn.cpp @@ -834,9 +834,13 @@ int SrsRtmpConn::publishing(SrsSource* source) // stop isolate recv thread trd.stop(); - - release_publish(source, vhost_is_edge); } + + // whatever the acquire publish, always release publish. + // when the acquire error in the midlle-way, the publish state changed, + // but failed, so we must cleanup it. + // @see https://github.com/simple-rtmp-server/srs/issues/474 + release_publish(source, vhost_is_edge); http_hooks_on_unpublish(); @@ -944,10 +948,12 @@ int SrsRtmpConn::acquire_publish(SrsSource* source, bool is_edge) if (is_edge) { if ((ret = source->on_edge_start_publish()) != ERROR_SUCCESS) { srs_error("notice edge start publish stream failed. ret=%d", ret); + return ret; } } else { if ((ret = source->on_publish()) != ERROR_SUCCESS) { srs_error("notify publish failed. ret=%d", ret); + return ret; } } diff --git a/trunk/src/app/srs_app_source.cpp b/trunk/src/app/srs_app_source.cpp index ec00978cc..4f08e774a 100755 --- a/trunk/src/app/srs_app_source.cpp +++ b/trunk/src/app/srs_app_source.cpp @@ -2066,6 +2066,7 @@ int SrsSource::on_publish() } SrsStatistic* stat = SrsStatistic::instance(); stat->on_stream_publish(_req, _source_id); + return ret; } diff --git a/trunk/src/app/srs_app_thread.cpp b/trunk/src/app/srs_app_thread.cpp index 097758563..d56624cd9 100644 --- a/trunk/src/app/srs_app_thread.cpp +++ b/trunk/src/app/srs_app_thread.cpp @@ -217,6 +217,8 @@ namespace internal { handler->on_thread_stop(); srs_info("thread %s cycle finished", _name); + + // TODO: FIXME: when thread terminated normally, set the tid to NULL. } void* SrsThread::thread_fun(void* arg)