1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

fix the utest bug

This commit is contained in:
winlin 2015-09-17 11:37:35 +08:00
parent 240a1bfadb
commit 256459e1ec
6 changed files with 116 additions and 76 deletions

View file

@ -429,6 +429,23 @@ int SrsConfDirective::parse_conf(SrsConfigBuffer* buffer, SrsDirectiveType type)
return ret;
}
SrsConfDirective* SrsConfDirective::copy()
{
SrsConfDirective* cp = new SrsConfDirective();
cp->conf_line = conf_line;
cp->name = name;
cp->args = args;
cp->create_time = create_time;
for (int i = 0; i < (int)directives.size(); i++) {
SrsConfDirective* directive = directives.at(i);
cp->directives.push_back(directive->copy());
}
return cp;
}
// see: ngx_conf_read_token
int SrsConfDirective::read_token(SrsConfigBuffer* buffer, vector<string>& args, int& line_start)
{
@ -527,7 +544,7 @@ int SrsConfDirective::read_token(SrsConfigBuffer* buffer, vector<string>& args,
continue;
}
} else {
// last charecter is not space
// last charecter is not space
if (line_start == 0) {
line_start = buffer->line;
}
@ -746,7 +763,6 @@ int SrsConfig::reload_vhost(SrsConfDirective* old_root)
// ENABLED => ENABLED (modified)
if (get_vhost_enabled(new_vhost) && get_vhost_enabled(old_vhost)) {
srs_trace("vhost %s maybe modified, reload its detail.", vhost.c_str());
// chunk_size, only one per vhost.
if (!srs_directive_equals(new_vhost->get("chunk_size"), old_vhost->get("chunk_size"))) {
for (it = subscribes.begin(); it != subscribes.end(); ++it) {
@ -3024,8 +3040,7 @@ int SrsConfig::check_config()
}
}
}
////////////////////////////////////////////////////////////////////////
// check listen for rtmp.
////////////////////////////////////////////////////////////////////////

1
trunk/src/app/srs_app_http_api.cpp Executable file → Normal file
View file

@ -1304,7 +1304,6 @@ int SrsGoApiError::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
return srs_api_response_code(w, r, 100);
}
SrsHttpApi::SrsHttpApi(IConnectionManager* cm, st_netfd_t fd, SrsHttpServeMux* m)
: SrsConnection(cm, fd)
{

View file

@ -77,7 +77,9 @@ int SrsHttpHooks::on_connect(string url, SrsRequest* req)
std::string data = obj->to_json();
std::string res;
int status_code;
if ((ret = do_post(url, data, status_code, res)) != ERROR_SUCCESS) {
SrsHttpClient http;
if ((ret = do_post(&http, url, data, status_code, res)) != ERROR_SUCCESS) {
srs_error("http post on_connect uri failed. "
"client_id=%d, url=%s, request=%s, response=%s, code=%d, ret=%d",
client_id, url.c_str(), data.c_str(), res.c_str(), status_code, ret);
@ -111,7 +113,9 @@ void SrsHttpHooks::on_close(string url, SrsRequest* req, int64_t send_bytes, int
std::string data = obj->to_json();
std::string res;
int status_code;
if ((ret = do_post(url, data, status_code, res)) != ERROR_SUCCESS) {
SrsHttpClient http;
if ((ret = do_post(&http, url, data, status_code, res)) != ERROR_SUCCESS) {
srs_warn("http post on_close uri failed, ignored. "
"client_id=%d, url=%s, request=%s, response=%s, code=%d, ret=%d",
client_id, url.c_str(), data.c_str(), res.c_str(), status_code, ret);
@ -144,7 +148,9 @@ int SrsHttpHooks::on_publish(string url, SrsRequest* req)
std::string data = obj->to_json();
std::string res;
int status_code;
if ((ret = do_post(url, data, status_code, res)) != ERROR_SUCCESS) {
SrsHttpClient http;
if ((ret = do_post(&http, url, data, status_code, res)) != ERROR_SUCCESS) {
srs_error("http post on_publish uri failed. "
"client_id=%d, url=%s, request=%s, response=%s, code=%d, ret=%d",
client_id, url.c_str(), data.c_str(), res.c_str(), status_code, ret);
@ -177,7 +183,9 @@ void SrsHttpHooks::on_unpublish(string url, SrsRequest* req)
std::string data = obj->to_json();
std::string res;
int status_code;
if ((ret = do_post(url, data, status_code, res)) != ERROR_SUCCESS) {
SrsHttpClient http;
if ((ret = do_post(&http, url, data, status_code, res)) != ERROR_SUCCESS) {
srs_warn("http post on_unpublish uri failed, ignored. "
"client_id=%d, url=%s, request=%s, response=%s, code=%d, ret=%d",
client_id, url.c_str(), data.c_str(), res.c_str(), status_code, ret);
@ -211,7 +219,9 @@ int SrsHttpHooks::on_play(string url, SrsRequest* req)
std::string data = obj->to_json();
std::string res;
int status_code;
if ((ret = do_post(url, data, status_code, res)) != ERROR_SUCCESS) {
SrsHttpClient http;
if ((ret = do_post(&http, url, data, status_code, res)) != ERROR_SUCCESS) {
srs_error("http post on_play uri failed. "
"client_id=%d, url=%s, request=%s, response=%s, code=%d, ret=%d",
client_id, url.c_str(), data.c_str(), res.c_str(), status_code, ret);
@ -244,7 +254,9 @@ void SrsHttpHooks::on_stop(string url, SrsRequest* req)
std::string data = obj->to_json();
std::string res;
int status_code;
if ((ret = do_post(url, data, status_code, res)) != ERROR_SUCCESS) {
SrsHttpClient http;
if ((ret = do_post(&http, url, data, status_code, res)) != ERROR_SUCCESS) {
srs_warn("http post on_stop uri failed, ignored. "
"client_id=%d, url=%s, request=%s, response=%s, code=%d, ret=%d",
client_id, url.c_str(), data.c_str(), res.c_str(), status_code, ret);
@ -280,7 +292,9 @@ int SrsHttpHooks::on_dvr(int cid, string url, SrsRequest* req, string file)
std::string data = obj->to_json();
std::string res;
int status_code;
if ((ret = do_post(url, data, status_code, res)) != ERROR_SUCCESS) {
SrsHttpClient http;
if ((ret = do_post(&http, url, data, status_code, res)) != ERROR_SUCCESS) {
srs_error("http post on_dvr uri failed, ignored. "
"client_id=%d, url=%s, request=%s, response=%s, code=%d, ret=%d",
client_id, url.c_str(), data.c_str(), res.c_str(), status_code, ret);
@ -321,7 +335,9 @@ int SrsHttpHooks::on_hls(int cid, string url, SrsRequest* req, string file, stri
std::string data = obj->to_json();
std::string res;
int status_code;
if ((ret = do_post(url, data, status_code, res)) != ERROR_SUCCESS) {
SrsHttpClient http;
if ((ret = do_post(&http, url, data, status_code, res)) != ERROR_SUCCESS) {
srs_error("http post on_hls uri failed, ignored. "
"client_id=%d, url=%s, request=%s, response=%s, code=%d, ret=%d",
client_id, url.c_str(), data.c_str(), res.c_str(), status_code, ret);
@ -403,7 +419,7 @@ int SrsHttpHooks::on_hls_notify(int cid, std::string url, SrsRequest* req, std::
return ret;
}
int SrsHttpHooks::do_post(std::string url, std::string req, int& code, string& res)
int SrsHttpHooks::do_post(SrsHttpClient* hc, std::string url, std::string req, int& code, string& res)
{
int ret = ERROR_SUCCESS;
@ -413,13 +429,12 @@ int SrsHttpHooks::do_post(std::string url, std::string req, int& code, string& r
return ret;
}
SrsHttpClient http;
if ((ret = http.initialize(uri.get_host(), uri.get_port())) != ERROR_SUCCESS) {
if ((ret = hc->initialize(uri.get_host(), uri.get_port())) != ERROR_SUCCESS) {
return ret;
}
ISrsHttpMessage* msg = NULL;
if ((ret = http.post(uri.get_path(), req, &msg)) != ERROR_SUCCESS) {
if ((ret = hc->post(uri.get_path(), req, &msg)) != ERROR_SUCCESS) {
return ret;
}
SrsAutoFree(ISrsHttpMessage, msg);

View file

@ -40,6 +40,7 @@ class SrsStSocket;
class SrsRequest;
class SrsHttpParser;
class SrsFlvSegment;
class SrsHttpClient;
/**
* the http hooks, http callback api,
@ -120,7 +121,7 @@ public:
*/
static int on_hls_notify(int cid, std::string url, SrsRequest* req, std::string ts_url, int nb_notify);
private:
static int do_post(std::string url, std::string req, int& code, std::string& res);
static int do_post(SrsHttpClient* hc, std::string url, std::string req, int& code, std::string& res);
};
#endif