diff --git a/README.md b/README.md
index c8d75404c..3872c971f 100755
--- a/README.md
+++ b/README.md
@@ -342,6 +342,7 @@ Remark:
## History
+* v3.0, 2015-08-31, fix [#319][bug #319], http raw api support query global and vhost. 3.0.3
* v3.0, 2015-08-28, fix [#471][bug #471], api response the width and height. 3.0.2
* v3.0, 2015-08-25, fix [#367][bug #367], support nginx-rtmp exec. 3.0.1
* v2.0, 2015-08-23, [2.0 alpha(2.0.185)][r2.0a0] released. 89022 lines.
@@ -1184,6 +1185,7 @@ Winlin
[bug #50]: https://github.com/simple-rtmp-server/srs/issues/50
[bug #34]: https://github.com/simple-rtmp-server/srs/issues/34
[bug #367]: https://github.com/simple-rtmp-server/srs/issues/367
+[bug #319]: https://github.com/simple-rtmp-server/srs/issues/319
[r2.0a0]: https://github.com/simple-rtmp-server/srs/releases/tag/2.0a0
[r1.0r4]: https://github.com/simple-rtmp-server/srs/releases/tag/1.0r4
diff --git a/trunk/src/app/srs_app_config.cpp b/trunk/src/app/srs_app_config.cpp
index 63afd9268..76ebe50ab 100644
--- a/trunk/src/app/srs_app_config.cpp
+++ b/trunk/src/app/srs_app_config.cpp
@@ -944,14 +944,9 @@ int SrsConfig::reload_conf(SrsConfig* conf)
// merge config: pid
if (!srs_directive_equals(root->get("pid"), old_root->get("pid"))) {
- for (it = subscribes.begin(); it != subscribes.end(); ++it) {
- ISrsReloadHandler* subscribe = *it;
- if ((ret = subscribe->on_reload_pid()) != ERROR_SUCCESS) {
- srs_error("notify subscribes reload pid failed. ret=%d", ret);
- return ret;
- }
+ if ((ret = do_reload_pid()) != ERROR_SUCCESS) {
+ return ret;
}
- srs_trace("reload pid success.");
}
// merge config: srs_log_tank
@@ -2213,21 +2208,47 @@ int SrsConfig::raw_set_listen(const vector& eps, bool& applied)
applied = false;
- SrsConfDirective* listen = root->get("listen");
+ SrsConfDirective* conf = root->get("listen");
// not changed, ignore.
- if (srs_vector_actual_equals(listen->args, eps)) {
+ if (srs_vector_actual_equals(conf->args, eps)) {
return ret;
}
// changed, apply and reload.
- listen->args = eps;
+ conf->args = eps;
if ((ret = do_reload_listen()) != ERROR_SUCCESS) {
return ret;
}
applied = true;
+
+ return ret;
+}
+
+int SrsConfig::raw_set_pid(string pid, bool& applied)
+{
+ int ret = ERROR_SUCCESS;
+
+ applied = false;
+
+
+ SrsConfDirective* conf = root->get_or_create("pid");
+
+ if (conf->arg0() == pid) {
+ return ret;
+ }
+
+ conf->args.clear();
+ conf->args.push_back(pid);
+
+ if ((ret = do_reload_pid()) != ERROR_SUCCESS) {
+ return ret;
+ }
+
+ applied = true;
+
return ret;
}
@@ -2235,7 +2256,6 @@ int SrsConfig::do_reload_listen()
{
int ret = ERROR_SUCCESS;
- // force to reload the memory server.
vector::iterator it;
for (it = subscribes.begin(); it != subscribes.end(); ++it) {
ISrsReloadHandler* subscribe = *it;
@@ -2249,6 +2269,23 @@ int SrsConfig::do_reload_listen()
return ret;
}
+int SrsConfig::do_reload_pid()
+{
+ int ret = ERROR_SUCCESS;
+
+ vector::iterator it;
+ for (it = subscribes.begin(); it != subscribes.end(); ++it) {
+ ISrsReloadHandler* subscribe = *it;
+ if ((ret = subscribe->on_reload_pid()) != ERROR_SUCCESS) {
+ srs_error("notify subscribes reload pid failed. ret=%d", ret);
+ return ret;
+ }
+ }
+ srs_trace("reload pid success.");
+
+ return ret;
+}
+
string SrsConfig::config()
{
return config_file;
diff --git a/trunk/src/app/srs_app_config.hpp b/trunk/src/app/srs_app_config.hpp
index 1beb577b3..1f066a003 100644
--- a/trunk/src/app/srs_app_config.hpp
+++ b/trunk/src/app/srs_app_config.hpp
@@ -331,14 +331,15 @@ public:
virtual int raw_to_json(SrsAmf0Object* obj);
/**
* raw set the global listen.
- * @param applied whether the config is applied.
*/
virtual int raw_set_listen(const std::vector& eps, bool& applied);
-private:
/**
- * do reload listen, for reload from signal or raw api.
+ * raw set the global pid.
*/
+ virtual int raw_set_pid(std::string pid, bool& applied);
+private:
virtual int do_reload_listen();
+ virtual int do_reload_pid();
public:
/**
* get the config file path.
diff --git a/trunk/src/app/srs_app_http_api.cpp b/trunk/src/app/srs_app_http_api.cpp
index f94da5217..7063001a4 100755
--- a/trunk/src/app/srs_app_http_api.cpp
+++ b/trunk/src/app/srs_app_http_api.cpp
@@ -977,6 +977,7 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
// possible updates:
// @param scope @param value value-description
// global.listen 1935,1936 the port list.
+ // global.pid ./objs/srs.pid the pid file of srs.
if (rpc == "update") {
if (!allow_update) {
ret = ERROR_SYSTEM_CONFIG_RAW_DISABLED;
@@ -986,7 +987,7 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
std::string scope = r->query_get("scope");
std::string value = r->query_get("value");
- if (scope.empty() || (scope != "global.listen")) {
+ if (scope.empty() || (scope != "global.listen" && scope != "global.pid")) {
ret = ERROR_SYSTEM_CONFIG_RAW_PARAMS;
srs_error("raw api query invalid scope=%s. ret=%d", scope.c_str(), ret);
return srs_api_response_code(w, r, ret);
@@ -1007,7 +1008,7 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
}
if (invalid) {
ret = ERROR_SYSTEM_CONFIG_RAW_PARAMS;
- srs_error("raw api update global.listen=%s failed. ret=%d", value.c_str(), ret);
+ srs_error("raw api update check global.listen=%s failed. ret=%d", value.c_str(), ret);
return srs_api_response_code(w, r, ret);
}
@@ -1015,6 +1016,26 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
srs_error("raw api update global.listen=%s failed. ret=%d", value.c_str(), ret);
return srs_api_response_code(w, r, ret);
}
+ } else if (scope == "global.pid") {
+ bool invalid = value.empty();
+ if (!invalid) {
+ invalid = !srs_string_starts_with(value, "./")
+ && !srs_string_starts_with(value, "/tmp")
+ && !srs_string_starts_with(value, "/var");
+ }
+ if (!invalid) {
+ invalid = !srs_string_ends_with(value, ".pid");
+ }
+ if (invalid) {
+ ret = ERROR_SYSTEM_CONFIG_RAW_PARAMS;
+ srs_error("raw api update check global.pid=%s failed. ret=%d", value.c_str(), ret);
+ return srs_api_response_code(w, r, ret);
+ }
+
+ if ((ret = _srs_config->raw_set_pid(value, applied)) != ERROR_SUCCESS) {
+ srs_error("raw api update global.pid=%s failed. ret=%d", value.c_str(), ret);
+ return srs_api_response_code(w, r, ret);
+ }
}
// whether the config applied.
diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp
index 0234eeefb..5efc3f734 100644
--- a/trunk/src/core/srs_core.hpp
+++ b/trunk/src/core/srs_core.hpp
@@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// current release version
#define VERSION_MAJOR 3
#define VERSION_MINOR 0
-#define VERSION_REVISION 2
+#define VERSION_REVISION 3
// server info.
#define RTMP_SIG_SRS_KEY "SRS"