[TD-5576]<fix>: fix localtime is unsafe in multi threads processing (#7045)
* [TD-5576]<fix>: fix localtime is unsafe in multi threads processing * remove unecessary debug line
This commit is contained in:
parent
0d7c2fb4af
commit
1d3df4a966
|
@ -264,8 +264,7 @@ void httpJsonUInt64(JsonBuf* buf, uint64_t num) {
|
|||
|
||||
void httpJsonTimestamp(JsonBuf* buf, int64_t t, int32_t timePrecision) {
|
||||
char ts[35] = {0};
|
||||
struct tm* ptm;
|
||||
|
||||
|
||||
int32_t fractionLen;
|
||||
char* format = NULL;
|
||||
time_t quot = 0;
|
||||
|
@ -301,8 +300,9 @@ void httpJsonTimestamp(JsonBuf* buf, int64_t t, int32_t timePrecision) {
|
|||
assert(false);
|
||||
}
|
||||
|
||||
ptm = localtime(");
|
||||
int32_t length = (int32_t)strftime(ts, 35, "%Y-%m-%d %H:%M:%S", ptm);
|
||||
struct tm ptm = {0};
|
||||
localtime_r(", &ptm);
|
||||
int32_t length = (int32_t)strftime(ts, 35, "%Y-%m-%d %H:%M:%S", &ptm);
|
||||
length += snprintf(ts + length, fractionLen, format, mod);
|
||||
|
||||
httpJsonString(buf, ts, length);
|
||||
|
|
Loading…
Reference in New Issue