diff --git a/README.md b/README.md index 43b806de1..4d8cad822 100755 --- a/README.md +++ b/README.md @@ -209,6 +209,7 @@ Please select your language: ### V2 changes +* v2.0, 2017-02-09, fix [#503][bug #503] disable utilities when reload a source. 2.0.233 * v2.0, 2017-01-22, for [#752][bug #752] release the io then free it for kbps. 2.0.232 * v2.0, 2017-01-18, fix [#750][bug #750] use specific error code for dns resolve. 2.0.231 * v2.0, 2017-01-18, [2.0 beta4(2.0.230)][r2.0b4] released. 86334 lines. @@ -1374,6 +1375,7 @@ Winlin [bug #749]: https://github.com/ossrs/srs/issues/749 [bug #750]: https://github.com/ossrs/srs/issues/750 [bug #752]: https://github.com/ossrs/srs/issues/752 +[bug #503]: https://github.com/ossrs/srs/issues/503 [bug #xxxxxxxxxx]: https://github.com/ossrs/srs/issues/xxxxxxxxxx [bug #735]: https://github.com/ossrs/srs/issues/735 diff --git a/trunk/conf/bandwidth.conf b/trunk/conf/bandwidth.conf index 33ce199b7..a0bf06004 100644 --- a/trunk/conf/bandwidth.conf +++ b/trunk/conf/bandwidth.conf @@ -3,6 +3,8 @@ listen 1935; max_connections 1000; +daemon off; +srs_log_tank console; vhost __defaultVhost__ { } diff --git a/trunk/conf/dvr.path.conf b/trunk/conf/dvr.path.conf index 238822614..bd43b4e8b 100644 --- a/trunk/conf/dvr.path.conf +++ b/trunk/conf/dvr.path.conf @@ -5,6 +5,8 @@ listen 1935; max_connections 1000; +daemon off; +srs_log_tank console; vhost __defaultVhost__ { dvr { enabled on; diff --git a/trunk/conf/dvr.segment.conf b/trunk/conf/dvr.segment.conf index 039f0cb79..2d6bf1bf8 100644 --- a/trunk/conf/dvr.segment.conf +++ b/trunk/conf/dvr.segment.conf @@ -4,6 +4,8 @@ listen 1935; max_connections 1000; +daemon off; +srs_log_tank console; vhost __defaultVhost__ { dvr { enabled on; diff --git a/trunk/conf/dvr.session.conf b/trunk/conf/dvr.session.conf index 5429d20ca..385980944 100644 --- a/trunk/conf/dvr.session.conf +++ b/trunk/conf/dvr.session.conf @@ -4,6 +4,8 @@ listen 1935; max_connections 1000; +daemon off; +srs_log_tank console; vhost __defaultVhost__ { dvr { enabled on; diff --git a/trunk/conf/edge.conf b/trunk/conf/edge.conf index 46de82102..36acb431f 100644 --- a/trunk/conf/edge.conf +++ b/trunk/conf/edge.conf @@ -5,7 +5,8 @@ listen 1935; max_connections 1000; pid objs/edge.pid; -srs_log_file ./objs/edge.log; +daemon off; +srs_log_tank console; vhost __defaultVhost__ { cluster { mode remote; diff --git a/trunk/conf/edge.token.traverse.conf b/trunk/conf/edge.token.traverse.conf index 399f3bab2..6fe35b7e2 100644 --- a/trunk/conf/edge.token.traverse.conf +++ b/trunk/conf/edge.token.traverse.conf @@ -4,6 +4,8 @@ listen 1935 max_connections 1000; +daemon off; +srs_log_tank console; vhost __defaultVhost__ { cluster { mode remote; diff --git a/trunk/conf/ffmpeg.transcode.conf b/trunk/conf/ffmpeg.transcode.conf index 1bb505556..d785a44ff 100644 --- a/trunk/conf/ffmpeg.transcode.conf +++ b/trunk/conf/ffmpeg.transcode.conf @@ -4,6 +4,8 @@ listen 1935; max_connections 1000; +daemon off; +srs_log_tank console; vhost __defaultVhost__ { transcode { enabled on; diff --git a/trunk/conf/forward.master.conf b/trunk/conf/forward.master.conf index bc141cf7a..630a4c84e 100644 --- a/trunk/conf/forward.master.conf +++ b/trunk/conf/forward.master.conf @@ -5,8 +5,8 @@ listen 1935; max_connections 1000; pid ./objs/srs.master.pid; -srs_log_tank file; -srs_log_file ./objs/srs.master.log; +daemon off; +srs_log_tank console; vhost __defaultVhost__ { forward { enabled on; diff --git a/trunk/conf/forward.slave.conf b/trunk/conf/forward.slave.conf index 37316c2f5..98286e33e 100644 --- a/trunk/conf/forward.slave.conf +++ b/trunk/conf/forward.slave.conf @@ -5,7 +5,7 @@ listen 19350; max_connections 1000; pid ./objs/srs.slave.pid; -srs_log_tank file; -srs_log_file ./objs/srs.slave.log; +daemon off; +srs_log_tank console; vhost __defaultVhost__ { } diff --git a/trunk/conf/hds.conf b/trunk/conf/hds.conf index 47811bcb7..c2a7d43ce 100644 --- a/trunk/conf/hds.conf +++ b/trunk/conf/hds.conf @@ -4,10 +4,8 @@ listen 1935; max_connections 1000; - daemon off; srs_log_tank console; -srs_log_level trace; vhost __defaultVhost__ { hds { diff --git a/trunk/conf/hls.conf b/trunk/conf/hls.conf index 8e1a09b65..d0fa42397 100644 --- a/trunk/conf/hls.conf +++ b/trunk/conf/hls.conf @@ -4,6 +4,8 @@ listen 1935; max_connections 1000; +daemon off; +srs_log_tank console; vhost __defaultVhost__ { hls { enabled on; diff --git a/trunk/conf/http.aac.live.conf b/trunk/conf/http.aac.live.conf index 52c885240..56a8387a6 100644 --- a/trunk/conf/http.aac.live.conf +++ b/trunk/conf/http.aac.live.conf @@ -4,6 +4,8 @@ listen 1935; max_connections 1000; +daemon off; +srs_log_tank console; http_server { enabled on; listen 8080; diff --git a/trunk/conf/http.flv.live.conf b/trunk/conf/http.flv.live.conf index 09ba1dffc..78c28546d 100644 --- a/trunk/conf/http.flv.live.conf +++ b/trunk/conf/http.flv.live.conf @@ -4,6 +4,8 @@ listen 1935; max_connections 1000; +daemon off; +srs_log_tank console; http_server { enabled on; listen 8080; diff --git a/trunk/conf/http.flv.live.edge1.conf b/trunk/conf/http.flv.live.edge1.conf index f77110219..23af7d1ca 100644 --- a/trunk/conf/http.flv.live.edge1.conf +++ b/trunk/conf/http.flv.live.edge1.conf @@ -5,7 +5,8 @@ listen 19351; max_connections 1000; pid objs/srs.flv.19351.pid; -srs_log_file objs/srs.flv.19351.log; +daemon off; +srs_log_tank console; http_server { enabled on; listen 8081; diff --git a/trunk/conf/http.flv.live.edge2.conf b/trunk/conf/http.flv.live.edge2.conf index a41c4a38f..fcf226066 100644 --- a/trunk/conf/http.flv.live.edge2.conf +++ b/trunk/conf/http.flv.live.edge2.conf @@ -5,7 +5,8 @@ listen 19352; max_connections 1000; pid objs/srs.flv.19352.pid; -srs_log_file objs/srs.flv.19352.log; +daemon off; +srs_log_tank console; http_server { enabled on; listen 8082; diff --git a/trunk/conf/http.heartbeat.conf b/trunk/conf/http.heartbeat.conf index b40287cfe..d15ff6a56 100644 --- a/trunk/conf/http.heartbeat.conf +++ b/trunk/conf/http.heartbeat.conf @@ -3,6 +3,8 @@ listen 1935 max_connections 1000; +daemon off; +srs_log_tank console; heartbeat { enabled on; interval 9.3; diff --git a/trunk/conf/http.hls.conf b/trunk/conf/http.hls.conf index 0b098779f..17416a294 100644 --- a/trunk/conf/http.hls.conf +++ b/trunk/conf/http.hls.conf @@ -4,6 +4,8 @@ listen 1935; max_connections 1000; +daemon off; +srs_log_tank console; http_server { enabled on; listen 8080; diff --git a/trunk/conf/http.hooks.callback.conf b/trunk/conf/http.hooks.callback.conf index 06d636569..d5374d907 100644 --- a/trunk/conf/http.hooks.callback.conf +++ b/trunk/conf/http.hooks.callback.conf @@ -3,8 +3,8 @@ listen 1935; max_connections 1000; -srs_log_tank file; -srs_log_file ./objs/srs.log; +daemon off; +srs_log_tank console; vhost __defaultVhost__ { http_hooks { enabled on; diff --git a/trunk/conf/http.mp3.live.conf b/trunk/conf/http.mp3.live.conf index be8edceb7..d07f62086 100644 --- a/trunk/conf/http.mp3.live.conf +++ b/trunk/conf/http.mp3.live.conf @@ -4,6 +4,8 @@ listen 1935; max_connections 1000; +daemon off; +srs_log_tank console; http_server { enabled on; listen 8080; diff --git a/trunk/conf/http.server.conf b/trunk/conf/http.server.conf index e424b9fc7..f3aafc079 100644 --- a/trunk/conf/http.server.conf +++ b/trunk/conf/http.server.conf @@ -3,6 +3,8 @@ listen 1935; max_connections 1000; +daemon off; +srs_log_tank console; http_server { enabled on; listen 8080; diff --git a/trunk/conf/http.ts.live.conf b/trunk/conf/http.ts.live.conf index d46c24b9c..db6978c70 100644 --- a/trunk/conf/http.ts.live.conf +++ b/trunk/conf/http.ts.live.conf @@ -4,6 +4,8 @@ listen 1935; max_connections 1000; +daemon off; +srs_log_tank console; http_server { enabled on; listen 8080; diff --git a/trunk/conf/ingest.conf b/trunk/conf/ingest.conf index 7b3d1c2ed..d77a2f954 100644 --- a/trunk/conf/ingest.conf +++ b/trunk/conf/ingest.conf @@ -4,6 +4,8 @@ listen 1935; max_connections 1000; +daemon off; +srs_log_tank console; vhost __defaultVhost__ { ingest livestream { enabled on; diff --git a/trunk/conf/origin.conf b/trunk/conf/origin.conf index 121624611..287d4e98e 100644 --- a/trunk/conf/origin.conf +++ b/trunk/conf/origin.conf @@ -4,7 +4,7 @@ listen 19350; max_connections 1000; -pid objs/origin.pid; -srs_log_file ./objs/origin.log; +daemon off; +srs_log_tank console; vhost __defaultVhost__ { } diff --git a/trunk/conf/push.flv.conf b/trunk/conf/push.flv.conf index 63357df55..9e871f913 100644 --- a/trunk/conf/push.flv.conf +++ b/trunk/conf/push.flv.conf @@ -4,6 +4,8 @@ listen 1935; max_connections 1000; +daemon off; +srs_log_tank console; http_server { enabled on; listen 8080; diff --git a/trunk/conf/push.mpegts.over.udp.conf b/trunk/conf/push.mpegts.over.udp.conf index 65e6df358..82f2f04c8 100644 --- a/trunk/conf/push.mpegts.over.udp.conf +++ b/trunk/conf/push.mpegts.over.udp.conf @@ -5,6 +5,8 @@ listen 1935; max_connections 1000; +daemon off; +srs_log_tank console; stream_caster { enabled on; caster mpegts_over_udp; diff --git a/trunk/conf/push.rtsp.conf b/trunk/conf/push.rtsp.conf index 619f74d90..016a06796 100644 --- a/trunk/conf/push.rtsp.conf +++ b/trunk/conf/push.rtsp.conf @@ -5,6 +5,8 @@ listen 1935; max_connections 1000; +daemon off; +srs_log_tank console; stream_caster { enabled on; caster rtsp; diff --git a/trunk/conf/realtime.conf b/trunk/conf/realtime.conf index 26b9b989f..482add3ea 100644 --- a/trunk/conf/realtime.conf +++ b/trunk/conf/realtime.conf @@ -4,6 +4,8 @@ listen 1935; max_connections 1000; +daemon off; +srs_log_tank console; vhost __defaultVhost__ { tcp_nodelay on min_latency on; diff --git a/trunk/conf/rtmp.conf b/trunk/conf/rtmp.conf index 94c740c50..e05f15408 100644 --- a/trunk/conf/rtmp.conf +++ b/trunk/conf/rtmp.conf @@ -4,5 +4,7 @@ listen 1935; max_connections 1000; +daemon off; +srs_log_tank console; vhost __defaultVhost__ { } diff --git a/trunk/conf/security.deny.publish.conf b/trunk/conf/security.deny.publish.conf index 0c71bb9b2..fc2a2e809 100644 --- a/trunk/conf/security.deny.publish.conf +++ b/trunk/conf/security.deny.publish.conf @@ -4,6 +4,8 @@ listen 1935; max_connections 1000; +daemon off; +srs_log_tank console; vhost __defaultVhost__ { security { enabled on; diff --git a/trunk/conf/transcode2hls.audio.only.conf b/trunk/conf/transcode2hls.audio.only.conf index 21a1e42b8..f4361bfaa 100644 --- a/trunk/conf/transcode2hls.audio.only.conf +++ b/trunk/conf/transcode2hls.audio.only.conf @@ -4,6 +4,8 @@ listen 1935; max_connections 1000; +daemon off; +srs_log_tank console; vhost __defaultVhost__ { hls { enabled on; diff --git a/trunk/conf/transform.edge.conf b/trunk/conf/transform.edge.conf index d878f6bdf..2b950f5be 100644 --- a/trunk/conf/transform.edge.conf +++ b/trunk/conf/transform.edge.conf @@ -4,6 +4,8 @@ listen 1935; max_connections 1000; +daemon off; +srs_log_tank console; vhost __defaultVhost__ { } vhost source.srs.com { diff --git a/trunk/src/app/srs_app_source.cpp b/trunk/src/app/srs_app_source.cpp index 4e11ef9cb..6fc607898 100755 --- a/trunk/src/app/srs_app_source.cpp +++ b/trunk/src/app/srs_app_source.cpp @@ -840,6 +840,7 @@ SrsOriginHub::SrsOriginHub(SrsSource* s) { source = s; req = NULL; + is_active = false; #ifdef SRS_AUTO_HLS hls = new SrsHls(); @@ -1141,11 +1142,15 @@ int SrsOriginHub::on_publish() return ret; } + is_active = true; + return ret; } void SrsOriginHub::on_unpublish() { + is_active = false; + // destroy all forwarders destroy_forwarders(); @@ -1261,6 +1266,12 @@ int SrsOriginHub::on_reload_vhost_forward(string vhost) // forwarders destroy_forwarders(); + + // Don't start forwarders when source is not active. + if (!is_active) { + return ret; + } + if ((ret = create_forwarders()) != ERROR_SUCCESS) { srs_error("create forwarders failed. ret=%d", ret); return ret; @@ -1283,6 +1294,12 @@ int SrsOriginHub::on_reload_vhost_hls(string vhost) #ifdef SRS_AUTO_HLS hls->on_unpublish(); + + // Don't start forwarders when source is not active. + if (!is_active) { + return ret; + } + if ((ret = hls->on_publish(true)) != ERROR_SUCCESS) { srs_error("hls publish failed. ret=%d", ret); return ret; @@ -1305,6 +1322,12 @@ int SrsOriginHub::on_reload_vhost_hds(string vhost) #ifdef SRS_AUTO_HDS hds->on_unpublish(); + + // Don't start forwarders when source is not active. + if (!is_active) { + return ret; + } + if ((ret = hds->on_publish(req)) != ERROR_SUCCESS) { srs_error("hds publish failed. ret=%d", ret); return ret; @@ -1329,6 +1352,11 @@ int SrsOriginHub::on_reload_vhost_dvr(string vhost) // cleanup dvr dvr->on_unpublish(); + // Don't start forwarders when source is not active. + if (!is_active) { + return ret; + } + // reinitialize the dvr, update plan. if ((ret = dvr->initialize(this, req)) != ERROR_SUCCESS) { return ret; @@ -1358,6 +1386,12 @@ int SrsOriginHub::on_reload_vhost_transcode(string vhost) #ifdef SRS_AUTO_TRANSCODE encoder->on_unpublish(); + + // Don't start forwarders when source is not active. + if (!is_active) { + return ret; + } + if ((ret = encoder->on_publish(req)) != ERROR_SUCCESS) { srs_error("start encoder failed. ret=%d", ret); return ret; @@ -1379,6 +1413,12 @@ int SrsOriginHub::on_reload_vhost_exec(string vhost) // TODO: FIXME: maybe should ignore when publish already stopped? ng_exec->on_unpublish(); + + // Don't start forwarders when source is not active. + if (!is_active) { + return ret; + } + if ((ret = ng_exec->on_publish(req)) != ERROR_SUCCESS) { srs_error("start exec failed. ret=%d", ret); return ret; diff --git a/trunk/src/app/srs_app_source.hpp b/trunk/src/app/srs_app_source.hpp index 56b3128a9..8b48cd5c9 100644 --- a/trunk/src/app/srs_app_source.hpp +++ b/trunk/src/app/srs_app_source.hpp @@ -421,6 +421,8 @@ class SrsOriginHub : public ISrsReloadHandler private: SrsSource* source; SrsRequest* req; + // Whether the stream hub is active, or stream is publishing. + bool is_active; private: // hls handler. #ifdef SRS_AUTO_HLS