From 4d4ccf6385085271c4a45b2277b223666666796c Mon Sep 17 00:00:00 2001 From: winlin Date: Tue, 27 Apr 2021 18:45:18 +0800 Subject: [PATCH] Threads: Remove reload for streams --- trunk/src/app/srs_app_caster_flv.cpp | 6 -- trunk/src/app/srs_app_caster_flv.hpp | 4 - trunk/src/app/srs_app_config.cpp | 117 ++----------------------- trunk/src/app/srs_app_config.hpp | 13 +-- trunk/src/app/srs_app_http_api.cpp | 40 +-------- trunk/src/app/srs_app_http_conn.cpp | 6 -- trunk/src/app/srs_app_http_conn.hpp | 3 - trunk/src/app/srs_app_reload.cpp | 25 ------ trunk/src/app/srs_app_reload.hpp | 5 -- trunk/src/app/srs_app_rtc_server.cpp | 36 -------- trunk/src/app/srs_app_rtc_server.hpp | 3 - trunk/src/app/srs_app_server.cpp | 39 --------- trunk/src/app/srs_app_server.hpp | 3 - trunk/src/app/srs_app_threads.cpp | 4 +- trunk/src/app/srs_app_threads.hpp | 2 +- trunk/src/utest/srs_utest_config.cpp | 4 + trunk/src/utest/srs_utest_reload.cpp | 122 --------------------------- trunk/src/utest/srs_utest_reload.hpp | 3 - 18 files changed, 17 insertions(+), 418 deletions(-) diff --git a/trunk/src/app/srs_app_caster_flv.cpp b/trunk/src/app/srs_app_caster_flv.cpp index 1cb912241e..bd3f9779cc 100644 --- a/trunk/src/app/srs_app_caster_flv.cpp +++ b/trunk/src/app/srs_app_caster_flv.cpp @@ -258,12 +258,6 @@ srs_error_t SrsDynamicHttpConn::do_proxy(ISrsHttpResponseReader* rr, SrsFlvDecod return err; } -srs_error_t SrsDynamicHttpConn::on_reload_http_stream_crossdomain() -{ - bool v = _srs_config->get_http_stream_crossdomain(); - return conn->set_crossdomain_enabled(v); -} - srs_error_t SrsDynamicHttpConn::on_start() { return srs_success; diff --git a/trunk/src/app/srs_app_caster_flv.hpp b/trunk/src/app/srs_app_caster_flv.hpp index 5042ebf6ef..3e0a6226bb 100644 --- a/trunk/src/app/srs_app_caster_flv.hpp +++ b/trunk/src/app/srs_app_caster_flv.hpp @@ -94,10 +94,6 @@ class SrsDynamicHttpConn : virtual public ISrsStartableConneciton, virtual publi virtual srs_error_t proxy(ISrsHttpResponseWriter* w, ISrsHttpMessage* r, std::string o); private: virtual srs_error_t do_proxy(ISrsHttpResponseReader* rr, SrsFlvDecoder* dec); -// Extract APIs from SrsTcpConnection. -// Interface ISrsReloadHandler -public: - virtual srs_error_t on_reload_http_stream_crossdomain(); // Interface ISrsHttpConnOwner. public: virtual srs_error_t on_start(); diff --git a/trunk/src/app/srs_app_config.cpp b/trunk/src/app/srs_app_config.cpp index 4038d4c5ce..641e550745 100644 --- a/trunk/src/app/srs_app_config.cpp +++ b/trunk/src/app/srs_app_config.cpp @@ -1654,13 +1654,6 @@ srs_error_t SrsConfig::reload_conf(SrsConfig* conf) // bandcheck, http_hooks, heartbeat, // security - // merge config: listen - if (!srs_directive_equals(root->get("listen"), old_root->get("listen"))) { - if ((err = do_reload_listen()) != srs_success) { - return srs_error_wrap(err, "listen"); - } - } - // merge config: pid if (!srs_directive_equals(root->get("pid"), old_root->get("pid"))) { if ((err = do_reload_pid()) != srs_success) { @@ -1668,13 +1661,6 @@ srs_error_t SrsConfig::reload_conf(SrsConfig* conf) } } - // merge config: max_connections - if (!srs_directive_equals(root->get("max_connections"), old_root->get("max_connections"))) { - if ((err = do_reload_max_connections()) != srs_success) { - return srs_error_wrap(err, "max connections");; - } - } - // merge config: pithy_print_ms if (!srs_directive_equals(root->get("pithy_print_ms"), old_root->get("pithy_print_ms"))) { if ((err = do_reload_pithy_print_ms()) != srs_success) { @@ -1686,15 +1672,10 @@ srs_error_t SrsConfig::reload_conf(SrsConfig* conf) if ((err = reload_http_api(old_root)) != srs_success) { return srs_error_wrap(err, "http api");; } - - // merge config: http_stream - if ((err = reload_http_stream(old_root)) != srs_success) { - return srs_error_wrap(err, "http steram");; - } - // Merge config: rtc_server - if ((err = reload_rtc_server(old_root)) != srs_success) { - return srs_error_wrap(err, "http steram");; + // merge config: streams + if ((err = reload_streams(old_root)) != srs_success) { + return srs_error_wrap(err, "streams");; } // TODO: FIXME: support reload stream_caster. @@ -1785,17 +1766,10 @@ srs_error_t SrsConfig::reload_http_api(SrsConfDirective* old_root) return err; } -srs_error_t SrsConfig::reload_http_stream(SrsConfDirective* old_root) -{ - srs_error_t err = srs_success; - // TODO: FIXME: We never support reload HTTP stream. - return err; -} - -srs_error_t SrsConfig::reload_rtc_server(SrsConfDirective* old_root) +srs_error_t SrsConfig::reload_streams(SrsConfDirective* old_root) { srs_error_t err = srs_success; - // TODO: FIXME: Do not support reloading RTC Server. + // TODO: FIXME: We never support reload streams. return err; } @@ -2901,31 +2875,6 @@ srs_error_t SrsConfig::raw_to_json(SrsJsonObject* obj) return err; } -srs_error_t SrsConfig::raw_set_listen(const vector& eps, bool& applied) -{ - srs_error_t err = srs_success; - - applied = false; - - SrsConfDirective* conf = root->get("listen"); - - // nothing changed, ignore. - if (srs_vector_actual_equals(conf->args, eps)) { - return err; - } - - // changed, apply and reload. - conf->args = eps; - - if ((err = do_reload_listen()) != srs_success) { - return srs_error_wrap(err, "reload listen"); - } - - applied = true; - - return err; -} - srs_error_t SrsConfig::raw_set_pid(string pid, bool& applied) { srs_error_t err = srs_success; @@ -2994,30 +2943,6 @@ srs_error_t SrsConfig::raw_set_ff_log_dir(string ff_log_dir, bool& applied) return err; } -srs_error_t SrsConfig::raw_set_max_connections(string max_connections, bool& applied) -{ - srs_error_t err = srs_success; - - applied = false; - - SrsConfDirective* conf = root->get_or_create("max_connections"); - - if (conf->arg0() == max_connections) { - return err; - } - - conf->args.clear(); - conf->args.push_back(max_connections); - - if ((err = do_reload_max_connections()) != srs_success) { - return srs_error_wrap(err, "reload max connection"); - } - - applied = true; - - return err; -} - srs_error_t SrsConfig::raw_set_pithy_print_ms(string pithy_print_ms, bool& applied) { srs_error_t err = srs_success; @@ -3185,22 +3110,6 @@ srs_error_t SrsConfig::raw_disable_dvr(string vhost, string stream, bool& applie } // LCOV_EXCL_STOP -srs_error_t SrsConfig::do_reload_listen() -{ - srs_error_t err = srs_success; - - vector::iterator it; - for (it = subscribes.begin(); it != subscribes.end(); ++it) { - ISrsReloadHandler* subscribe = *it; - if ((err = subscribe->on_reload_listen()) != srs_success) { - return srs_error_wrap(err, "notify subscribes reload listen failed"); - } - } - srs_trace("reload listen success."); - - return err; -} - srs_error_t SrsConfig::do_reload_pid() { srs_error_t err = srs_success; @@ -3217,22 +3126,6 @@ srs_error_t SrsConfig::do_reload_pid() return err; } -srs_error_t SrsConfig::do_reload_max_connections() -{ - srs_error_t err = srs_success; - - vector::iterator it; - for (it = subscribes.begin(); it != subscribes.end(); ++it) { - ISrsReloadHandler* subscribe = *it; - if ((err = subscribe->on_reload_max_conns()) != srs_success) { - return srs_error_wrap(err, "notify subscribes reload max_connections failed"); - } - } - srs_trace("reload max_connections success."); - - return err; -} - srs_error_t SrsConfig::do_reload_pithy_print_ms() { srs_error_t err = srs_success; diff --git a/trunk/src/app/srs_app_config.hpp b/trunk/src/app/srs_app_config.hpp index 27db20f986..f476b64c40 100644 --- a/trunk/src/app/srs_app_config.hpp +++ b/trunk/src/app/srs_app_config.hpp @@ -326,11 +326,8 @@ class SrsConfig private: // Reload the http_api section of config. virtual srs_error_t reload_http_api(SrsConfDirective* old_root); - // Reload the http_stream section of config. - // TODO: FIXME: rename to http_server. - virtual srs_error_t reload_http_stream(SrsConfDirective* old_root); - // Reload the rtc_server section of config. - virtual srs_error_t reload_rtc_server(SrsConfDirective* old_root); + // Reload the streams for hybrids. + virtual srs_error_t reload_streams(SrsConfDirective* old_root); // Reload the transcode section of vhost of config. virtual srs_error_t reload_transcode(SrsConfDirective* new_vhost, SrsConfDirective* old_vhost); // Reload the ingest section of vhost of config. @@ -355,16 +352,12 @@ class SrsConfig virtual srs_error_t vhost_to_json(SrsConfDirective* vhost, SrsJsonObject* obj); // Dumps the http_api sections to json for raw api info. virtual srs_error_t raw_to_json(SrsJsonObject* obj); - // RAW set the global listen. - virtual srs_error_t raw_set_listen(const std::vector& eps, bool& applied); // RAW set the global pid. virtual srs_error_t raw_set_pid(std::string pid, bool& applied); // RAW set the global chunk size. virtual srs_error_t raw_set_chunk_size(std::string chunk_size, bool& applied); // RAW set the global ffmpeg log dir. virtual srs_error_t raw_set_ff_log_dir(std::string ff_log_dir, bool& applied); - // RAW set the global max connections of srs. - virtual srs_error_t raw_set_max_connections(std::string max_connections, bool& applied); // RAW set the global pithy print interval in ms. virtual srs_error_t raw_set_pithy_print_ms(std::string pithy_print_ms, bool& applied); // RAW create the new vhost. @@ -382,9 +375,7 @@ class SrsConfig // RAW disable the dvr of stream of vhost. virtual srs_error_t raw_disable_dvr(std::string vhost, std::string stream, bool& applied); private: - virtual srs_error_t do_reload_listen(); virtual srs_error_t do_reload_pid(); - virtual srs_error_t do_reload_max_connections(); virtual srs_error_t do_reload_pithy_print_ms(); virtual srs_error_t do_reload_vhost_added(std::string vhost); virtual srs_error_t do_reload_vhost_removed(std::string vhost); diff --git a/trunk/src/app/srs_app_http_api.cpp b/trunk/src/app/srs_app_http_api.cpp index 35619a46f7..61b369bc73 100644 --- a/trunk/src/app/srs_app_http_api.cpp +++ b/trunk/src/app/srs_app_http_api.cpp @@ -993,14 +993,12 @@ srs_error_t SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* // @data the extra data for scope. // possible updates: // @scope @value value-description - // listen 1935,1936 the port list. // pid ./objs/srs.pid the pid file of srs. // chunk_size 60000 the global RTMP chunk_size. // ff_log_dir ./objs the dir for ffmpeg log. // srs_log_tank file the tank to log, file or console. // srs_log_level trace the level of log, verbose, info, trace, warn, error. // srs_log_file ./objs/srs.log the log file when tank is file. - // max_connections 1000 the max connections of srs. // utc_time false whether enable utc time. // pithy_print_ms 10000 the pithy print interval in ms. // vhost specified updates: @@ -1021,9 +1019,9 @@ srs_error_t SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* if (scope.empty()) { return srs_api_response_code(w, r, ERROR_SYSTEM_CONFIG_RAW_NOT_ALLOWED); } - if (scope != "listen" && scope != "pid" && scope != "chunk_size" + if (scope != "pid" && scope != "chunk_size" && scope != "ff_log_dir" && scope != "srs_log_tank" && scope != "srs_log_level" - && scope != "srs_log_file" && scope != "max_connections" && scope != "utc_time" + && scope != "srs_log_file" && scope != "utc_time" && scope != "pithy_print_ms" && scope != "vhost" && scope != "dvr" ) { return srs_api_response_code(w, r, ERROR_SYSTEM_CONFIG_RAW_NOT_ALLOWED); @@ -1031,28 +1029,7 @@ srs_error_t SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* bool applied = false; string extra = ""; - if (scope == "listen") { - vector eps = srs_string_split(value, ","); - - bool invalid = eps.empty(); - for (int i = 0; i < (int)eps.size(); i++) { - string ep = eps.at(i); - int port = ::atoi(ep.c_str()); - if (port <= 2 || port >= 65535) { - invalid = true; - break; - } - } - if (invalid) { - return srs_api_response_code(w, r, ERROR_SYSTEM_CONFIG_RAW_PARAMS); - } - - if ((err = _srs_config->raw_set_listen(eps, applied)) != srs_success) { - int code = srs_error_code(err); - srs_error_reset(err); - return srs_api_response_code(w, r, code); - } - } else if (scope == "pid") { + if (scope == "pid") { if (value.empty() || !srs_string_starts_with(value, "./", "/tmp/", "/var/") || !srs_string_ends_with(value, ".pid")) { return srs_api_response_code(w, r, ERROR_SYSTEM_CONFIG_RAW_PARAMS); } @@ -1083,17 +1060,6 @@ srs_error_t SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* srs_error_reset(err); return srs_api_response_code(w, r, code); } - } else if (scope == "max_connections") { - int mcv = ::atoi(value.c_str()); - if (mcv < 10 || mcv > 65535 || !srs_is_digit_number(value)) { - return srs_api_response_code(w, r, ERROR_SYSTEM_CONFIG_RAW_PARAMS); - } - - if ((err = _srs_config->raw_set_max_connections(value, applied)) != srs_success) { - int code = srs_error_code(err); - srs_error_reset(err); - return srs_api_response_code(w, r, code); - } } else if (scope == "pithy_print_ms") { int ppmv = ::atoi(value.c_str()); if (ppmv < 100 || ppmv > 300000 || !srs_is_digit_number(value)) { diff --git a/trunk/src/app/srs_app_http_conn.cpp b/trunk/src/app/srs_app_http_conn.cpp index 729ce21710..4826653ab7 100644 --- a/trunk/src/app/srs_app_http_conn.cpp +++ b/trunk/src/app/srs_app_http_conn.cpp @@ -366,12 +366,6 @@ srs_error_t SrsResponseOnlyHttpConn::pop_message(ISrsHttpMessage** preq) return err; } -srs_error_t SrsResponseOnlyHttpConn::on_reload_http_stream_crossdomain() -{ - bool v = _srs_config->get_http_stream_crossdomain(); - return conn->set_crossdomain_enabled(v); -} - srs_error_t SrsResponseOnlyHttpConn::on_start() { srs_error_t err = srs_success; diff --git a/trunk/src/app/srs_app_http_conn.hpp b/trunk/src/app/srs_app_http_conn.hpp index b7c2b7fb3d..527c0919e0 100644 --- a/trunk/src/app/srs_app_http_conn.hpp +++ b/trunk/src/app/srs_app_http_conn.hpp @@ -162,9 +162,6 @@ class SrsResponseOnlyHttpConn : virtual public ISrsStartableConneciton, virtual // @see https://github.com/ossrs/srs/issues/636#issuecomment-298208427 // @remark Should only used in HTTP-FLV streaming connection. virtual srs_error_t pop_message(ISrsHttpMessage** preq); -// Interface ISrsReloadHandler -public: - virtual srs_error_t on_reload_http_stream_crossdomain(); // Interface ISrsHttpConnOwner. public: virtual srs_error_t on_start(); diff --git a/trunk/src/app/srs_app_reload.cpp b/trunk/src/app/srs_app_reload.cpp index 4c9256b6b5..027ebb93b4 100644 --- a/trunk/src/app/srs_app_reload.cpp +++ b/trunk/src/app/srs_app_reload.cpp @@ -85,31 +85,6 @@ srs_error_t ISrsReloadHandler::on_reload_http_api_raw_api() return srs_success; } -srs_error_t ISrsReloadHandler::on_reload_http_stream_enabled() -{ - return srs_success; -} - -srs_error_t ISrsReloadHandler::on_reload_http_stream_disabled() -{ - return srs_success; -} - -srs_error_t ISrsReloadHandler::on_reload_http_stream_updated() -{ - return srs_success; -} - -srs_error_t ISrsReloadHandler::on_reload_http_stream_crossdomain() -{ - return srs_success; -} - -srs_error_t ISrsReloadHandler::on_reload_rtc_server() -{ - return srs_success; -} - srs_error_t ISrsReloadHandler::on_reload_vhost_http_updated() { return srs_success; diff --git a/trunk/src/app/srs_app_reload.hpp b/trunk/src/app/srs_app_reload.hpp index a63e2b5d83..eebcacf15d 100644 --- a/trunk/src/app/srs_app_reload.hpp +++ b/trunk/src/app/srs_app_reload.hpp @@ -49,11 +49,6 @@ class ISrsReloadHandler virtual srs_error_t on_reload_https_api_disabled(); virtual srs_error_t on_reload_http_api_crossdomain(); virtual srs_error_t on_reload_http_api_raw_api(); - virtual srs_error_t on_reload_http_stream_enabled(); - virtual srs_error_t on_reload_http_stream_disabled(); - virtual srs_error_t on_reload_http_stream_updated(); - virtual srs_error_t on_reload_http_stream_crossdomain(); - virtual srs_error_t on_reload_rtc_server(); public: // TODO: FIXME: should rename to http_static virtual srs_error_t on_reload_vhost_http_updated(); diff --git a/trunk/src/app/srs_app_rtc_server.cpp b/trunk/src/app/srs_app_rtc_server.cpp index 2deca9cd68..cc5b85a46e 100644 --- a/trunk/src/app/srs_app_rtc_server.cpp +++ b/trunk/src/app/srs_app_rtc_server.cpp @@ -319,42 +319,6 @@ srs_error_t SrsRtcServer::initialize() return err; } -srs_error_t SrsRtcServer::on_reload_rtc_server() -{ - bool changed = false; - - bool rtp_cache_enabled = _srs_config->get_rtc_server_rtp_cache_enabled(); - uint64_t rtp_cache_pkt_size = _srs_config->get_rtc_server_rtp_cache_pkt_size(); - uint64_t rtp_cache_payload_size = _srs_config->get_rtc_server_rtp_cache_payload_size(); - if (_srs_rtp_cache->enabled() != rtp_cache_enabled) { - _srs_rtp_cache->setup(rtp_cache_enabled, rtp_cache_pkt_size); - _srs_rtp_raw_cache->setup(rtp_cache_enabled, rtp_cache_payload_size); - _srs_rtp_fua_cache->setup(rtp_cache_enabled, rtp_cache_payload_size); - - changed = true; - } - - bool rtp_msg_cache_enabled = _srs_config->get_rtc_server_rtp_msg_cache_enabled(); - uint64_t rtp_msg_cache_msg_size = _srs_config->get_rtc_server_rtp_msg_cache_msg_size(); - uint64_t rtp_msg_cache_buffer_size = _srs_config->get_rtc_server_rtp_msg_cache_buffer_size(); - if (_srs_rtp_msg_cache_buffers->enabled() != rtp_msg_cache_enabled) { - _srs_rtp_msg_cache_buffers->setup(rtp_msg_cache_enabled, rtp_msg_cache_buffer_size); - _srs_rtp_msg_cache_objs->setup(rtp_msg_cache_enabled, rtp_msg_cache_msg_size); - - changed = true; - } - - if (changed) { - srs_trace("RTC: Object cache reload, rtp-cache=(enabled:%d,pkt:%dm-%dw,payload:%dm-%dw-%dw), msg-cache=(enabled:%d,obj:%dm-%dw,buf:%dm-%dw)", - rtp_cache_enabled, (int)(rtp_cache_pkt_size/1024/1024), _srs_rtp_cache->capacity()/10000, - (int)(rtp_cache_payload_size/1024/1024), _srs_rtp_raw_cache->capacity()/10000, _srs_rtp_fua_cache->capacity()/10000, - rtp_msg_cache_enabled, (int)(rtp_msg_cache_msg_size/1024/1024), _srs_rtp_msg_cache_objs->capacity()/10000, - (int)(rtp_msg_cache_buffer_size/1024/1024), _srs_rtp_msg_cache_buffers->capacity()/10000); - } - - return srs_success; -} - void SrsRtcServer::set_handler(ISrsRtcServerHandler* h) { handler = h; diff --git a/trunk/src/app/srs_app_rtc_server.hpp b/trunk/src/app/srs_app_rtc_server.hpp index ac9c727cb2..9ea1e67ea0 100644 --- a/trunk/src/app/srs_app_rtc_server.hpp +++ b/trunk/src/app/srs_app_rtc_server.hpp @@ -117,9 +117,6 @@ class SrsRtcServer : public ISrsUdpMuxHandler, public ISrsFastTimer, public ISrs virtual ~SrsRtcServer(); public: virtual srs_error_t initialize(); -// interface ISrsReloadHandler -public: - virtual srs_error_t on_reload_rtc_server(); public: // Set the handler for server events. void set_handler(ISrsRtcServerHandler* h); diff --git a/trunk/src/app/srs_app_server.cpp b/trunk/src/app/srs_app_server.cpp index a8b940d5d0..d9bf74101e 100644 --- a/trunk/src/app/srs_app_server.cpp +++ b/trunk/src/app/srs_app_server.cpp @@ -1516,45 +1516,6 @@ srs_error_t SrsServer::on_reload_http_api_disabled() return srs_success; } -srs_error_t SrsServer::on_reload_http_stream_enabled() -{ - srs_error_t err = srs_success; - - if ((err = listen_http_stream()) != srs_success) { - return srs_error_wrap(err, "reload http_stream enabled"); - } - - if ((err = listen_https_stream()) != srs_success) { - return srs_error_wrap(err, "reload https_stream enabled"); - } - - return err; -} - -srs_error_t SrsServer::on_reload_http_stream_disabled() -{ - close_listeners(SrsListenerHttpStream); - close_listeners(SrsListenerHttpsStream); - return srs_success; -} - -// TODO: FIXME: rename to http_remux -srs_error_t SrsServer::on_reload_http_stream_updated() -{ - srs_error_t err = srs_success; - - if ((err = on_reload_http_stream_enabled()) != srs_success) { - return srs_error_wrap(err, "reload http_stream updated"); - } - - // TODO: FIXME: should handle the event in SrsHttpStaticServer - if ((err = on_reload_vhost_http_updated()) != srs_success) { - return srs_error_wrap(err, "reload http_stream updated"); - } - - return err; -} - srs_error_t SrsServer::on_publish(SrsSource* s, SrsRequest* r) { srs_error_t err = srs_success; diff --git a/trunk/src/app/srs_app_server.hpp b/trunk/src/app/srs_app_server.hpp index 40426b936b..94821e8785 100644 --- a/trunk/src/app/srs_app_server.hpp +++ b/trunk/src/app/srs_app_server.hpp @@ -385,9 +385,6 @@ class SrsServer : virtual public ISrsReloadHandler, virtual public ISrsSourceHan virtual srs_error_t on_reload_vhost_removed(std::string vhost); virtual srs_error_t on_reload_http_api_enabled(); virtual srs_error_t on_reload_http_api_disabled(); - virtual srs_error_t on_reload_http_stream_enabled(); - virtual srs_error_t on_reload_http_stream_disabled(); - virtual srs_error_t on_reload_http_stream_updated(); // Interface ISrsSourceHandler public: virtual srs_error_t on_publish(SrsSource* s, SrsRequest* r); diff --git a/trunk/src/app/srs_app_threads.cpp b/trunk/src/app/srs_app_threads.cpp index 9dcd82365d..38e900e361 100644 --- a/trunk/src/app/srs_app_threads.cpp +++ b/trunk/src/app/srs_app_threads.cpp @@ -107,7 +107,7 @@ srs_error_t SrsCircuitBreaker::initialize() srs_error_t err = srs_success; // Start a timer to stat the data for circuit breaker. - _srs_hybrid->timer()->subscribe(1 * SRS_UTIME_SECONDS, this); + _srs_hybrid->timer1s()->subscribe(this); enabled_ = _srs_config->get_circuit_breaker(); high_threshold_ = _srs_config->get_high_threshold(); @@ -138,7 +138,7 @@ bool SrsCircuitBreaker::hybrid_dying_water_level() return enabled_ && (dying_pulse_ && hybrid_dying_water_level_ >= dying_pulse_); } -srs_error_t SrsCircuitBreaker::on_timer(srs_utime_t interval, srs_utime_t tick) +srs_error_t SrsCircuitBreaker::on_timer(srs_utime_t interval) { srs_error_t err = srs_success; diff --git a/trunk/src/app/srs_app_threads.hpp b/trunk/src/app/srs_app_threads.hpp index 7e29ea0e86..4de50199b1 100644 --- a/trunk/src/app/srs_app_threads.hpp +++ b/trunk/src/app/srs_app_threads.hpp @@ -76,7 +76,7 @@ class SrsCircuitBreaker : public ISrsFastTimer bool hybrid_dying_water_level(); // interface ISrsFastTimer private: - srs_error_t on_timer(srs_utime_t interval, srs_utime_t tick); + srs_error_t on_timer(srs_utime_t interval); }; extern __thread SrsCircuitBreaker* _srs_circuit_breaker; diff --git a/trunk/src/utest/srs_utest_config.cpp b/trunk/src/utest/srs_utest_config.cpp index 5441e9123f..fc1dd9cd99 100644 --- a/trunk/src/utest/srs_utest_config.cpp +++ b/trunk/src/utest/srs_utest_config.cpp @@ -81,6 +81,10 @@ srs_error_t MockSrsConfig::parse(string buf) return srs_error_wrap(err, "transform config"); } + if ((err = srs_config_transform_vhost2(root)) != srs_success) { + return srs_error_wrap(err, "transform config"); + } + if ((err = check_normal_config()) != srs_success) { return srs_error_wrap(err, "check normal config"); } diff --git a/trunk/src/utest/srs_utest_reload.cpp b/trunk/src/utest/srs_utest_reload.cpp index d3779ba821..d57d3ce940 100644 --- a/trunk/src/utest/srs_utest_reload.cpp +++ b/trunk/src/utest/srs_utest_reload.cpp @@ -185,24 +185,6 @@ srs_error_t MockReloadHandler::on_reload_http_api_disabled() return srs_success; } -srs_error_t MockReloadHandler::on_reload_http_stream_enabled() -{ - http_stream_enabled_reloaded = true; - return srs_success; -} - -srs_error_t MockReloadHandler::on_reload_http_stream_disabled() -{ - http_stream_disabled_reloaded = true; - return srs_success; -} - -srs_error_t MockReloadHandler::on_reload_http_stream_updated() -{ - http_stream_updated_reloaded = true; - return srs_success; -} - srs_error_t MockReloadHandler::on_reload_vhost_http_updated() { vhost_http_updated_reloaded = true; @@ -310,47 +292,6 @@ VOID TEST(ConfigReloadTest, ReloadEmpty) EXPECT_TRUE(handler.all_false()); } -VOID TEST(ConfigReloadTest, ReloadListen) -{ - MockReloadHandler handler; - MockSrsReloadConfig conf; - - conf.subscribe(&handler); - EXPECT_TRUE(ERROR_SUCCESS == conf.parse("listen 1935;")); - EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload("listen 1935;")); - EXPECT_TRUE(handler.all_false()); - handler.reset(); - - EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload("listen 1936;")); - EXPECT_TRUE(handler.listen_reloaded); - EXPECT_EQ(1, handler.count_true()); - handler.reset(); - - EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload("listen 1936;")); - EXPECT_TRUE(handler.all_false()); - handler.reset(); - - EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload("listen 1936 1935;")); - EXPECT_TRUE(handler.listen_reloaded); - EXPECT_EQ(1, handler.count_true()); - handler.reset(); - - EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload("listen 1935;")); - EXPECT_TRUE(handler.listen_reloaded); - EXPECT_EQ(1, handler.count_true()); - handler.reset(); - - EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload("listen 1935 1935;")); - EXPECT_TRUE(handler.listen_reloaded); - EXPECT_EQ(1, handler.count_true()); - handler.reset(); - - EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload("listen 1935;")); - EXPECT_TRUE(handler.listen_reloaded); - EXPECT_EQ(1, handler.count_true()); - handler.reset(); -} - VOID TEST(ConfigReloadTest, ReloadPid) { MockReloadHandler handler; @@ -435,69 +376,6 @@ VOID TEST(ConfigReloadTest, ReloadHttpApiDisabled) handler.reset(); } -VOID TEST(ConfigReloadTest, ReloadHttpStreamEnabled) -{ - MockReloadHandler handler; - MockSrsReloadConfig conf; - - conf.subscribe(&handler); - EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"http_stream {enabled off;}")); - EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"http_stream {enabled off;}")); - EXPECT_TRUE(handler.all_false()); - handler.reset(); - - EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"http_stream {enabled on;}")); - EXPECT_TRUE(handler.http_stream_enabled_reloaded); - EXPECT_EQ(1, handler.count_true()); - handler.reset(); - - EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"http_stream {enabled off;}")); - EXPECT_EQ(1, handler.count_true()); - handler.reset(); -} - -VOID TEST(ConfigReloadTest, ReloadHttpStreamDisabled) -{ - MockReloadHandler handler; - MockSrsReloadConfig conf; - - conf.subscribe(&handler); - EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"http_stream {enabled on;}")); - EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"http_stream {enabled on;}")); - EXPECT_TRUE(handler.all_false()); - handler.reset(); - - EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"http_stream {enabled off;}")); - EXPECT_TRUE(handler.http_stream_disabled_reloaded); - EXPECT_EQ(1, handler.count_true()); - handler.reset(); - - EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"http_stream {enabled on;}")); - EXPECT_EQ(1, handler.count_true()); - handler.reset(); -} - -VOID TEST(ConfigReloadTest, ReloadHttpStreamUpdated) -{ - MockReloadHandler handler; - MockSrsReloadConfig conf; - - conf.subscribe(&handler); - EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"http_stream {enabled on; listen 8080;}")); - EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"http_stream {enabled on; listen 8080;}")); - EXPECT_TRUE(handler.all_false()); - handler.reset(); - - EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"http_stream {enabled on; listen 8000;}")); - EXPECT_TRUE(handler.http_stream_updated_reloaded); - EXPECT_EQ(1, handler.count_true()); - handler.reset(); - - EXPECT_TRUE(ERROR_SUCCESS == conf.do_reload(_MIN_OK_CONF"http_stream {enabled on; listen 8080;}")); - EXPECT_EQ(1, handler.count_true()); - handler.reset(); -} - VOID TEST(ConfigReloadTest, ReloadVhostHttpUpdated) { MockReloadHandler handler; diff --git a/trunk/src/utest/srs_utest_reload.hpp b/trunk/src/utest/srs_utest_reload.hpp index 71e14ca4c4..f1e980d75d 100644 --- a/trunk/src/utest/srs_utest_reload.hpp +++ b/trunk/src/utest/srs_utest_reload.hpp @@ -76,9 +76,6 @@ class MockReloadHandler : public ISrsReloadHandler virtual srs_error_t on_reload_pithy_print(); virtual srs_error_t on_reload_http_api_enabled(); virtual srs_error_t on_reload_http_api_disabled(); - virtual srs_error_t on_reload_http_stream_enabled(); - virtual srs_error_t on_reload_http_stream_disabled(); - virtual srs_error_t on_reload_http_stream_updated(); virtual srs_error_t on_reload_vhost_http_updated(); virtual srs_error_t on_reload_vhost_added(std::string vhost); virtual srs_error_t on_reload_vhost_removed(std::string vhost);