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

For #1657, refine code

This commit is contained in:
winlin 2020-11-07 07:39:50 +08:00
parent 5709ee1b63
commit 32c1832d64
5 changed files with 39 additions and 20 deletions

View file

@ -1676,6 +1676,9 @@ srs_error_t SrsGoApiTcmalloc::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMess
SrsHttpApi::SrsHttpApi(bool https, ISrsResourceManager* cm, srs_netfd_t fd, SrsHttpServeMux* m, string cip, int port)
{
// Create a identify for this client.
_srs_context->set_id(_srs_context->generate_id());
manager = cm;
skt = new SrsTcpConnection(fd);
@ -1703,20 +1706,22 @@ srs_error_t SrsHttpApi::on_start()
{
srs_error_t err = srs_success;
srs_utime_t starttime = srs_update_system_time();
string crt_file = _srs_config->get_https_api_ssl_cert();
string key_file = _srs_config->get_https_api_ssl_key();
if (ssl && (err = ssl->handshake(key_file, crt_file)) != srs_success) {
return srs_error_wrap(err, "handshake");
}
if ((err = conn->set_jsonp(true)) != srs_success) {
return srs_error_wrap(err, "set jsonp");
}
int cost = srsu2msi(srs_update_system_time() - starttime);
srs_trace("https: api server done, use key %s and cert %s, cost=%dms",
key_file.c_str(), crt_file.c_str(), cost);
if (ssl) {
srs_utime_t starttime = srs_update_system_time();
string crt_file = _srs_config->get_https_api_ssl_cert();
string key_file = _srs_config->get_https_api_ssl_key();
if ((err = ssl->handshake(key_file, crt_file)) != srs_success) {
return srs_error_wrap(err, "handshake");
}
int cost = srsu2msi(srs_update_system_time() - starttime);
srs_trace("https: api server done, use key %s and cert %s, cost=%dms",
key_file.c_str(), crt_file.c_str(), cost);
}
return err;
}