Fix bugs and enhance code. 4.0.142

pull/2486/head
winlin 4 years ago
parent 66a696efe0
commit afa32910c9

@ -18,7 +18,8 @@ on:
# The branches below must be a subset of the branches above
branches: [ 4.0release, develop ]
schedule:
- cron: '43 11 * * 0'
# '20 19 * * 6' means 'At 19:20, only on Saturday' @see https://crontab.cronhub.io/
- cron: '20 19 * * 6'
jobs:
analyze:

1
.gitignore vendored

@ -40,3 +40,4 @@ cmake-build-debug
/trunk/ide/srs_clion/Makefile
/trunk/ide/srs_clion/cmake_install.cmake
/trunk/ide/srs_clion/srs
/trunk/ide/srs_clion/Testing/

@ -6,6 +6,7 @@ The changelog for SRS.
## SRS 4.0 Changelog
* v4.0, 2021-07-17, Fix bugs and enhance code. 4.0.142
* v4.0, 2021-07-16, Support [CLion and cmake](https://github.com/ossrs/srs/wiki/v4_CN_IDE#clion) to build and debug SRS. 4.0.141
* v4.0, 2021-07-08, For [#2403](https://github.com/ossrs/srs/issues/2403), fix padding packets for RTMP2RTC. 4.0.140
* v4.0, 2021-07-04, For [#2424](https://github.com/ossrs/srs/issues/2424), use srandom/random to generate. 4.0.139

@ -80,13 +80,14 @@ string srs_path_build_timestamp(string template_path)
}
// to calendar time
struct tm* tm;
struct tm now;
// Each of these functions returns NULL in case an error was detected. @see https://linux.die.net/man/3/localtime_r
if (_srs_config->get_utc_time()) {
if ((tm = gmtime(&tv.tv_sec)) == NULL) {
if (gmtime_r(&tv.tv_sec, &now) == NULL) {
return path;
}
} else {
if ((tm = localtime(&tv.tv_sec)) == NULL) {
if (localtime_r(&tv.tv_sec, &now) == NULL) {
return path;
}
}
@ -96,32 +97,32 @@ string srs_path_build_timestamp(string template_path)
// [2006], replace with current year.
if (true) {
snprintf(buf, sizeof(buf), "%04d", 1900 + tm->tm_year);
snprintf(buf, sizeof(buf), "%04d", 1900 + now.tm_year);
path = srs_string_replace(path, "[2006]", buf);
}
// [01], replace this const to current month.
if (true) {
snprintf(buf, sizeof(buf), "%02d", 1 + tm->tm_mon);
snprintf(buf, sizeof(buf), "%02d", 1 + now.tm_mon);
path = srs_string_replace(path, "[01]", buf);
}
// [02], replace this const to current date.
if (true) {
snprintf(buf, sizeof(buf), "%02d", tm->tm_mday);
snprintf(buf, sizeof(buf), "%02d", now.tm_mday);
path = srs_string_replace(path, "[02]", buf);
}
// [15], replace this const to current hour.
if (true) {
snprintf(buf, sizeof(buf), "%02d", tm->tm_hour);
snprintf(buf, sizeof(buf), "%02d", now.tm_hour);
path = srs_string_replace(path, "[15]", buf);
}
// [04], repleace this const to current minute.
if (true) {
snprintf(buf, sizeof(buf), "%02d", tm->tm_min);
snprintf(buf, sizeof(buf), "%02d", now.tm_min);
path = srs_string_replace(path, "[04]", buf);
}
// [05], repleace this const to current second.
if (true) {
snprintf(buf, sizeof(buf), "%02d", tm->tm_sec);
snprintf(buf, sizeof(buf), "%02d", now.tm_sec);
path = srs_string_replace(path, "[05]", buf);
}
// [999], repleace this const to current millisecond.

@ -9,6 +9,6 @@
#define VERSION_MAJOR 4
#define VERSION_MINOR 0
#define VERSION_REVISION 141
#define VERSION_REVISION 142
#endif

@ -217,13 +217,14 @@ bool srs_log_header(char* buffer, int size, bool utc, bool dangerous, const char
}
// to calendar time
struct tm* tm;
struct tm now;
// Each of these functions returns NULL in case an error was detected. @see https://linux.die.net/man/3/localtime_r
if (utc) {
if ((tm = gmtime(&tv.tv_sec)) == NULL) {
if (gmtime_r(&tv.tv_sec, &now) == NULL) {
return false;
}
} else {
if ((tm = localtime(&tv.tv_sec)) == NULL) {
if (localtime_r(&tv.tv_sec, &now) == NULL) {
return false;
}
}
@ -233,24 +234,24 @@ bool srs_log_header(char* buffer, int size, bool utc, bool dangerous, const char
if (tag) {
written = snprintf(buffer, size,
"[%d-%02d-%02d %02d:%02d:%02d.%03d][%s][%d][%s][%d][%s] ",
1900 + tm->tm_year, 1 + tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, (int)(tv.tv_usec / 1000),
1900 + now.tm_year, 1 + now.tm_mon, now.tm_mday, now.tm_hour, now.tm_min, now.tm_sec, (int)(tv.tv_usec / 1000),
level, getpid(), cid.c_str(), errno, tag);
} else {
written = snprintf(buffer, size,
"[%d-%02d-%02d %02d:%02d:%02d.%03d][%s][%d][%s][%d] ",
1900 + tm->tm_year, 1 + tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, (int)(tv.tv_usec / 1000),
1900 + now.tm_year, 1 + now.tm_mon, now.tm_mday, now.tm_hour, now.tm_min, now.tm_sec, (int)(tv.tv_usec / 1000),
level, getpid(), cid.c_str(), errno);
}
} else {
if (tag) {
written = snprintf(buffer, size,
"[%d-%02d-%02d %02d:%02d:%02d.%03d][%s][%d][%s][%s] ",
1900 + tm->tm_year, 1 + tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, (int)(tv.tv_usec / 1000),
1900 + now.tm_year, 1 + now.tm_mon, now.tm_mday, now.tm_hour, now.tm_min, now.tm_sec, (int)(tv.tv_usec / 1000),
level, getpid(), cid.c_str(), tag);
} else {
written = snprintf(buffer, size,
"[%d-%02d-%02d %02d:%02d:%02d.%03d][%s][%d][%s] ",
1900 + tm->tm_year, 1 + tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, (int)(tv.tv_usec / 1000),
1900 + now.tm_year, 1 + now.tm_mon, now.tm_mday, now.tm_hour, now.tm_min, now.tm_sec, (int)(tv.tv_usec / 1000),
level, getpid(), cid.c_str());
}
}

Loading…
Cancel
Save