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

support reload utc_time. 2.0.186

This commit is contained in:
winlin 2015-09-09 23:37:07 +08:00
parent 0221434ae9
commit abd7ee227c
7 changed files with 34 additions and 3 deletions

View file

@ -957,12 +957,24 @@ int SrsConfig::reload_conf(SrsConfig* conf)
srs_trace("reload srs_log_file success.");
}
// merge config: utc_time
if (!srs_directive_equals(root->get("utc_time"), old_root->get("utc_time"))) {
for (it = subscribes.begin(); it != subscribes.end(); ++it) {
ISrsReloadHandler* subscribe = *it;
if ((ret = subscribe->on_reload_utc_time()) != ERROR_SUCCESS) {
srs_error("notify subscribes reload utc_time failed. ret=%d", ret);
return ret;
}
}
srs_trace("reload utc_time success.");
}
// merge config: pithy_print_ms
if (!srs_directive_equals(root->get("pithy_print_ms"), old_root->get("pithy_print_ms"))) {
for (it = subscribes.begin(); it != subscribes.end(); ++it) {
ISrsReloadHandler* subscribe = *it;
if ((ret = subscribe->on_reload_pithy_print()) != ERROR_SUCCESS) {
srs_error("notify subscribes pithy_print_ms listen failed. ret=%d", ret);
srs_error("notify subscribes pithy_print_ms failed. ret=%d", ret);
return ret;
}
}

View file

@ -86,6 +86,7 @@ SrsFastLog::SrsFastLog()
fd = -1;
log_to_file_tank = false;
utc = false;
}
SrsFastLog::~SrsFastLog()
@ -111,6 +112,7 @@ int SrsFastLog::initialize()
log_to_file_tank = _srs_config->get_log_tank_file();
_level = srs_get_log_level(_srs_config->get_log_level());
utc = _srs_config->get_utc_time();
}
return ret;
@ -221,6 +223,13 @@ void SrsFastLog::error(const char* tag, int context_id, const char* fmt, ...)
write_log(fd, log_data, size, SrsLogLevel::Error);
}
int SrsFastLog::on_reload_utc_time()
{
utc = _srs_config->get_utc_time();
return ERROR_SUCCESS;
}
int SrsFastLog::on_reload_log_tank()
{
int ret = ERROR_SUCCESS;
@ -291,7 +300,7 @@ bool SrsFastLog::generate_header(bool error, const char* tag, int context_id, co
// to calendar time
struct tm* tm;
if (_srs_config && _srs_config->get_utc_time()) {
if (utc) {
if ((tm = gmtime(&tv.tv_sec)) == NULL) {
return false;
}

View file

@ -73,6 +73,8 @@ private:
int fd;
// whether log to file tank
bool log_to_file_tank;
// whether use utc time.
bool utc;
public:
SrsFastLog();
virtual ~SrsFastLog();
@ -85,6 +87,7 @@ public:
virtual void error(const char* tag, int context_id, const char* fmt, ...);
// interface ISrsReloadHandler.
public:
virtual int on_reload_utc_time();
virtual int on_reload_log_tank();
virtual int on_reload_log_level();
virtual int on_reload_log_file();

View file

@ -40,6 +40,11 @@ int ISrsReloadHandler::on_reload_listen()
return ERROR_SUCCESS;
}
int ISrsReloadHandler::on_reload_utc_time()
{
return ERROR_SUCCESS;
}
int ISrsReloadHandler::on_reload_max_conns()
{
return ERROR_SUCCESS;

View file

@ -44,6 +44,7 @@ public:
ISrsReloadHandler();
virtual ~ISrsReloadHandler();
public:
virtual int on_reload_utc_time();
virtual int on_reload_max_conns();
virtual int on_reload_listen();
virtual int on_reload_pid();