diff --git a/trunk/src/core/srs_core_client.cpp b/trunk/src/core/srs_core_client.cpp index 163b76187..17d7583f8 100644 --- a/trunk/src/core/srs_core_client.cpp +++ b/trunk/src/core/srs_core_client.cpp @@ -63,6 +63,8 @@ SrsClient::SrsClient(SrsServer* srs_server, st_netfd_t client_stfd) SrsClient::~SrsClient() { + config->unsubscribe(this); + srs_freepa(ip); srs_freep(req); srs_freep(res); @@ -71,8 +73,6 @@ SrsClient::~SrsClient() #ifdef SRS_HTTP srs_freep(http_hooks); #endif - - config->unsubscribe(this); } // TODO: return detail message when error for client. diff --git a/trunk/src/core/srs_core_config.cpp b/trunk/src/core/srs_core_config.cpp index d29a4d1f4..a373f3563 100644 --- a/trunk/src/core/srs_core_config.cpp +++ b/trunk/src/core/srs_core_config.cpp @@ -537,6 +537,7 @@ int SrsConfig::reload() // merge config: vhost modified. srs_trace("vhost %s modified, reload its detail.", vhost.c_str()); if (get_vhost_enabled(new_vhost) && get_vhost_enabled(old_vhost)) { + // gop_cache if (!srs_directive_equals(new_vhost->get("gop_cache"), old_vhost->get("gop_cache"))) { for (it = subscribes.begin(); it != subscribes.end(); ++it) { ISrsReloadHandler* subscribe = *it; @@ -547,6 +548,17 @@ int SrsConfig::reload() } srs_trace("vhost %s reload gop_cache success.", vhost.c_str()); } + // forward + if (!srs_directive_equals(new_vhost->get("forward"), old_vhost->get("forward"))) { + for (it = subscribes.begin(); it != subscribes.end(); ++it) { + ISrsReloadHandler* subscribe = *it; + if ((ret = subscribe->on_reload_forward(vhost)) != ERROR_SUCCESS) { + srs_error("vhost %s notify subscribes forward failed. ret=%d", vhost.c_str(), ret); + return ret; + } + } + srs_trace("vhost %s reload forward success.", vhost.c_str()); + } // TODO: suppor reload hls/forward/ffmpeg/http continue; } diff --git a/trunk/src/core/srs_core_reload.cpp b/trunk/src/core/srs_core_reload.cpp index d27cefac5..7e6752ea6 100644 --- a/trunk/src/core/srs_core_reload.cpp +++ b/trunk/src/core/srs_core_reload.cpp @@ -55,3 +55,8 @@ int ISrsReloadHandler::on_reload_gop_cache(string /*vhost*/) return ERROR_SUCCESS; } +int ISrsReloadHandler::on_reload_forward(string /*vhost*/) +{ + return ERROR_SUCCESS; +} + diff --git a/trunk/src/core/srs_core_reload.hpp b/trunk/src/core/srs_core_reload.hpp index 01a31a787..9f40927b7 100644 --- a/trunk/src/core/srs_core_reload.hpp +++ b/trunk/src/core/srs_core_reload.hpp @@ -44,6 +44,7 @@ public: virtual int on_reload_pithy_print(); virtual int on_reload_vhost_removed(std::string vhost); virtual int on_reload_gop_cache(std::string vhost); + virtual int on_reload_forward(std::string vhost); }; #endif \ No newline at end of file diff --git a/trunk/src/core/srs_core_source.cpp b/trunk/src/core/srs_core_source.cpp index f58c9aa57..cf405f100 100644 --- a/trunk/src/core/srs_core_source.cpp +++ b/trunk/src/core/srs_core_source.cpp @@ -374,10 +374,14 @@ SrsSource::SrsSource(string _stream_url, string _vhost) _can_publish = true; gop_cache = new SrsGopCache(); + + config->subscribe(this); } SrsSource::~SrsSource() { + config->unsubscribe(this); + if (true) { std::vector::iterator it; for (it = consumers.begin(); it != consumers.end(); ++it) {