service_logger.c localtime崩溃,换成线程安全的localtime_r (#1311)

This commit is contained in:
coder
2020-12-28 15:42:16 +08:00
committed by GitHub
parent 4d88f96ed6
commit 284df5430b

View File

@@ -38,8 +38,9 @@ static int
timestring(struct logger *inst, char tmp[SIZETIMEFMT]) {
uint64_t now = skynet_now();
time_t ti = now/100 + inst->starttime;
struct tm *info = localtime(&ti);
strftime(tmp, SIZETIMEFMT, "%D %T", info);
struct tm info;
(void)localtime_r(&ti,&info);
strftime(tmp, SIZETIMEFMT, "%D %T", &info);
return now % 100;
}