正在显示
5 个修改的文件
包含
78 行增加
和
17 行删除
| @@ -342,6 +342,7 @@ Remark: | @@ -342,6 +342,7 @@ Remark: | ||
| 342 | 342 | ||
| 343 | ## History | 343 | ## History |
| 344 | 344 | ||
| 345 | +* v3.0, 2015-08-31, fix [#319][bug #319], http raw api support query global and vhost. 3.0.3 | ||
| 345 | * v3.0, 2015-08-28, fix [#471][bug #471], api response the width and height. 3.0.2 | 346 | * v3.0, 2015-08-28, fix [#471][bug #471], api response the width and height. 3.0.2 |
| 346 | * v3.0, 2015-08-25, fix [#367][bug #367], support nginx-rtmp exec. 3.0.1 | 347 | * v3.0, 2015-08-25, fix [#367][bug #367], support nginx-rtmp exec. 3.0.1 |
| 347 | * <strong>v2.0, 2015-08-23, [2.0 alpha(2.0.185)][r2.0a0] released. 89022 lines.</strong> | 348 | * <strong>v2.0, 2015-08-23, [2.0 alpha(2.0.185)][r2.0a0] released. 89022 lines.</strong> |
| @@ -1184,6 +1185,7 @@ Winlin | @@ -1184,6 +1185,7 @@ Winlin | ||
| 1184 | [bug #50]: https://github.com/simple-rtmp-server/srs/issues/50 | 1185 | [bug #50]: https://github.com/simple-rtmp-server/srs/issues/50 |
| 1185 | [bug #34]: https://github.com/simple-rtmp-server/srs/issues/34 | 1186 | [bug #34]: https://github.com/simple-rtmp-server/srs/issues/34 |
| 1186 | [bug #367]: https://github.com/simple-rtmp-server/srs/issues/367 | 1187 | [bug #367]: https://github.com/simple-rtmp-server/srs/issues/367 |
| 1188 | +[bug #319]: https://github.com/simple-rtmp-server/srs/issues/319 | ||
| 1187 | 1189 | ||
| 1188 | [r2.0a0]: https://github.com/simple-rtmp-server/srs/releases/tag/2.0a0 | 1190 | [r2.0a0]: https://github.com/simple-rtmp-server/srs/releases/tag/2.0a0 |
| 1189 | [r1.0r4]: https://github.com/simple-rtmp-server/srs/releases/tag/1.0r4 | 1191 | [r1.0r4]: https://github.com/simple-rtmp-server/srs/releases/tag/1.0r4 |
| @@ -944,14 +944,9 @@ int SrsConfig::reload_conf(SrsConfig* conf) | @@ -944,14 +944,9 @@ int SrsConfig::reload_conf(SrsConfig* conf) | ||
| 944 | 944 | ||
| 945 | // merge config: pid | 945 | // merge config: pid |
| 946 | if (!srs_directive_equals(root->get("pid"), old_root->get("pid"))) { | 946 | if (!srs_directive_equals(root->get("pid"), old_root->get("pid"))) { |
| 947 | - for (it = subscribes.begin(); it != subscribes.end(); ++it) { | ||
| 948 | - ISrsReloadHandler* subscribe = *it; | ||
| 949 | - if ((ret = subscribe->on_reload_pid()) != ERROR_SUCCESS) { | ||
| 950 | - srs_error("notify subscribes reload pid failed. ret=%d", ret); | ||
| 951 | - return ret; | ||
| 952 | - } | 947 | + if ((ret = do_reload_pid()) != ERROR_SUCCESS) { |
| 948 | + return ret; | ||
| 953 | } | 949 | } |
| 954 | - srs_trace("reload pid success."); | ||
| 955 | } | 950 | } |
| 956 | 951 | ||
| 957 | // merge config: srs_log_tank | 952 | // merge config: srs_log_tank |
| @@ -2213,21 +2208,47 @@ int SrsConfig::raw_set_listen(const vector<string>& eps, bool& applied) | @@ -2213,21 +2208,47 @@ int SrsConfig::raw_set_listen(const vector<string>& eps, bool& applied) | ||
| 2213 | 2208 | ||
| 2214 | applied = false; | 2209 | applied = false; |
| 2215 | 2210 | ||
| 2216 | - SrsConfDirective* listen = root->get("listen"); | 2211 | + SrsConfDirective* conf = root->get("listen"); |
| 2217 | 2212 | ||
| 2218 | // not changed, ignore. | 2213 | // not changed, ignore. |
| 2219 | - if (srs_vector_actual_equals(listen->args, eps)) { | 2214 | + if (srs_vector_actual_equals(conf->args, eps)) { |
| 2220 | return ret; | 2215 | return ret; |
| 2221 | } | 2216 | } |
| 2222 | 2217 | ||
| 2223 | // changed, apply and reload. | 2218 | // changed, apply and reload. |
| 2224 | - listen->args = eps; | 2219 | + conf->args = eps; |
| 2225 | 2220 | ||
| 2226 | if ((ret = do_reload_listen()) != ERROR_SUCCESS) { | 2221 | if ((ret = do_reload_listen()) != ERROR_SUCCESS) { |
| 2227 | return ret; | 2222 | return ret; |
| 2228 | } | 2223 | } |
| 2229 | 2224 | ||
| 2230 | applied = true; | 2225 | applied = true; |
| 2226 | + | ||
| 2227 | + return ret; | ||
| 2228 | +} | ||
| 2229 | + | ||
| 2230 | +int SrsConfig::raw_set_pid(string pid, bool& applied) | ||
| 2231 | +{ | ||
| 2232 | + int ret = ERROR_SUCCESS; | ||
| 2233 | + | ||
| 2234 | + applied = false; | ||
| 2235 | + | ||
| 2236 | + | ||
| 2237 | + SrsConfDirective* conf = root->get_or_create("pid"); | ||
| 2238 | + | ||
| 2239 | + if (conf->arg0() == pid) { | ||
| 2240 | + return ret; | ||
| 2241 | + } | ||
| 2242 | + | ||
| 2243 | + conf->args.clear(); | ||
| 2244 | + conf->args.push_back(pid); | ||
| 2245 | + | ||
| 2246 | + if ((ret = do_reload_pid()) != ERROR_SUCCESS) { | ||
| 2247 | + return ret; | ||
| 2248 | + } | ||
| 2249 | + | ||
| 2250 | + applied = true; | ||
| 2251 | + | ||
| 2231 | return ret; | 2252 | return ret; |
| 2232 | } | 2253 | } |
| 2233 | 2254 | ||
| @@ -2235,7 +2256,6 @@ int SrsConfig::do_reload_listen() | @@ -2235,7 +2256,6 @@ int SrsConfig::do_reload_listen() | ||
| 2235 | { | 2256 | { |
| 2236 | int ret = ERROR_SUCCESS; | 2257 | int ret = ERROR_SUCCESS; |
| 2237 | 2258 | ||
| 2238 | - // force to reload the memory server. | ||
| 2239 | vector<ISrsReloadHandler*>::iterator it; | 2259 | vector<ISrsReloadHandler*>::iterator it; |
| 2240 | for (it = subscribes.begin(); it != subscribes.end(); ++it) { | 2260 | for (it = subscribes.begin(); it != subscribes.end(); ++it) { |
| 2241 | ISrsReloadHandler* subscribe = *it; | 2261 | ISrsReloadHandler* subscribe = *it; |
| @@ -2249,6 +2269,23 @@ int SrsConfig::do_reload_listen() | @@ -2249,6 +2269,23 @@ int SrsConfig::do_reload_listen() | ||
| 2249 | return ret; | 2269 | return ret; |
| 2250 | } | 2270 | } |
| 2251 | 2271 | ||
| 2272 | +int SrsConfig::do_reload_pid() | ||
| 2273 | +{ | ||
| 2274 | + int ret = ERROR_SUCCESS; | ||
| 2275 | + | ||
| 2276 | + vector<ISrsReloadHandler*>::iterator it; | ||
| 2277 | + for (it = subscribes.begin(); it != subscribes.end(); ++it) { | ||
| 2278 | + ISrsReloadHandler* subscribe = *it; | ||
| 2279 | + if ((ret = subscribe->on_reload_pid()) != ERROR_SUCCESS) { | ||
| 2280 | + srs_error("notify subscribes reload pid failed. ret=%d", ret); | ||
| 2281 | + return ret; | ||
| 2282 | + } | ||
| 2283 | + } | ||
| 2284 | + srs_trace("reload pid success."); | ||
| 2285 | + | ||
| 2286 | + return ret; | ||
| 2287 | +} | ||
| 2288 | + | ||
| 2252 | string SrsConfig::config() | 2289 | string SrsConfig::config() |
| 2253 | { | 2290 | { |
| 2254 | return config_file; | 2291 | return config_file; |
| @@ -331,14 +331,15 @@ public: | @@ -331,14 +331,15 @@ public: | ||
| 331 | virtual int raw_to_json(SrsAmf0Object* obj); | 331 | virtual int raw_to_json(SrsAmf0Object* obj); |
| 332 | /** | 332 | /** |
| 333 | * raw set the global listen. | 333 | * raw set the global listen. |
| 334 | - * @param applied whether the config is applied. | ||
| 335 | */ | 334 | */ |
| 336 | virtual int raw_set_listen(const std::vector<std::string>& eps, bool& applied); | 335 | virtual int raw_set_listen(const std::vector<std::string>& eps, bool& applied); |
| 337 | -private: | ||
| 338 | /** | 336 | /** |
| 339 | - * do reload listen, for reload from signal or raw api. | 337 | + * raw set the global pid. |
| 340 | */ | 338 | */ |
| 339 | + virtual int raw_set_pid(std::string pid, bool& applied); | ||
| 340 | +private: | ||
| 341 | virtual int do_reload_listen(); | 341 | virtual int do_reload_listen(); |
| 342 | + virtual int do_reload_pid(); | ||
| 342 | public: | 343 | public: |
| 343 | /** | 344 | /** |
| 344 | * get the config file path. | 345 | * get the config file path. |
| @@ -977,6 +977,7 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | @@ -977,6 +977,7 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | ||
| 977 | // possible updates: | 977 | // possible updates: |
| 978 | // @param scope @param value value-description | 978 | // @param scope @param value value-description |
| 979 | // global.listen 1935,1936 the port list. | 979 | // global.listen 1935,1936 the port list. |
| 980 | + // global.pid ./objs/srs.pid the pid file of srs. | ||
| 980 | if (rpc == "update") { | 981 | if (rpc == "update") { |
| 981 | if (!allow_update) { | 982 | if (!allow_update) { |
| 982 | ret = ERROR_SYSTEM_CONFIG_RAW_DISABLED; | 983 | ret = ERROR_SYSTEM_CONFIG_RAW_DISABLED; |
| @@ -986,7 +987,7 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | @@ -986,7 +987,7 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | ||
| 986 | 987 | ||
| 987 | std::string scope = r->query_get("scope"); | 988 | std::string scope = r->query_get("scope"); |
| 988 | std::string value = r->query_get("value"); | 989 | std::string value = r->query_get("value"); |
| 989 | - if (scope.empty() || (scope != "global.listen")) { | 990 | + if (scope.empty() || (scope != "global.listen" && scope != "global.pid")) { |
| 990 | ret = ERROR_SYSTEM_CONFIG_RAW_PARAMS; | 991 | ret = ERROR_SYSTEM_CONFIG_RAW_PARAMS; |
| 991 | srs_error("raw api query invalid scope=%s. ret=%d", scope.c_str(), ret); | 992 | srs_error("raw api query invalid scope=%s. ret=%d", scope.c_str(), ret); |
| 992 | return srs_api_response_code(w, r, ret); | 993 | return srs_api_response_code(w, r, ret); |
| @@ -1007,7 +1008,7 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | @@ -1007,7 +1008,7 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | ||
| 1007 | } | 1008 | } |
| 1008 | if (invalid) { | 1009 | if (invalid) { |
| 1009 | ret = ERROR_SYSTEM_CONFIG_RAW_PARAMS; | 1010 | ret = ERROR_SYSTEM_CONFIG_RAW_PARAMS; |
| 1010 | - srs_error("raw api update global.listen=%s failed. ret=%d", value.c_str(), ret); | 1011 | + srs_error("raw api update check global.listen=%s failed. ret=%d", value.c_str(), ret); |
| 1011 | return srs_api_response_code(w, r, ret); | 1012 | return srs_api_response_code(w, r, ret); |
| 1012 | } | 1013 | } |
| 1013 | 1014 | ||
| @@ -1015,6 +1016,26 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | @@ -1015,6 +1016,26 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) | ||
| 1015 | srs_error("raw api update global.listen=%s failed. ret=%d", value.c_str(), ret); | 1016 | srs_error("raw api update global.listen=%s failed. ret=%d", value.c_str(), ret); |
| 1016 | return srs_api_response_code(w, r, ret); | 1017 | return srs_api_response_code(w, r, ret); |
| 1017 | } | 1018 | } |
| 1019 | + } else if (scope == "global.pid") { | ||
| 1020 | + bool invalid = value.empty(); | ||
| 1021 | + if (!invalid) { | ||
| 1022 | + invalid = !srs_string_starts_with(value, "./") | ||
| 1023 | + && !srs_string_starts_with(value, "/tmp") | ||
| 1024 | + && !srs_string_starts_with(value, "/var"); | ||
| 1025 | + } | ||
| 1026 | + if (!invalid) { | ||
| 1027 | + invalid = !srs_string_ends_with(value, ".pid"); | ||
| 1028 | + } | ||
| 1029 | + if (invalid) { | ||
| 1030 | + ret = ERROR_SYSTEM_CONFIG_RAW_PARAMS; | ||
| 1031 | + srs_error("raw api update check global.pid=%s failed. ret=%d", value.c_str(), ret); | ||
| 1032 | + return srs_api_response_code(w, r, ret); | ||
| 1033 | + } | ||
| 1034 | + | ||
| 1035 | + if ((ret = _srs_config->raw_set_pid(value, applied)) != ERROR_SUCCESS) { | ||
| 1036 | + srs_error("raw api update global.pid=%s failed. ret=%d", value.c_str(), ret); | ||
| 1037 | + return srs_api_response_code(w, r, ret); | ||
| 1038 | + } | ||
| 1018 | } | 1039 | } |
| 1019 | 1040 | ||
| 1020 | // whether the config applied. | 1041 | // whether the config applied. |
| @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 31 | // current release version | 31 | // current release version |
| 32 | #define VERSION_MAJOR 3 | 32 | #define VERSION_MAJOR 3 |
| 33 | #define VERSION_MINOR 0 | 33 | #define VERSION_MINOR 0 |
| 34 | -#define VERSION_REVISION 2 | 34 | +#define VERSION_REVISION 3 |
| 35 | 35 | ||
| 36 | // server info. | 36 | // server info. |
| 37 | #define RTMP_SIG_SRS_KEY "SRS" | 37 | #define RTMP_SIG_SRS_KEY "SRS" |
-
请 注册 或 登录 后发表评论