!454 解决gmtime和localtime接口由于g_tm全局变量导致的竞态问题
Merge pull request !454 from JerryH/time
This commit is contained in:
commit
a1b4ebd479
|
@ -542,7 +542,8 @@ struct tm *gmtime_r(const time_t *timep, struct tm *result)
|
||||||
|
|
||||||
struct tm *gmtime(const time_t *timer)
|
struct tm *gmtime(const time_t *timer)
|
||||||
{
|
{
|
||||||
return gmtime_r(timer, &g_tm);
|
static struct tm tm;
|
||||||
|
return gmtime_r(timer, &tm);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct tm *localtime_r(const time_t *timep, struct tm *result)
|
struct tm *localtime_r(const time_t *timep, struct tm *result)
|
||||||
|
@ -560,7 +561,8 @@ struct tm *localtime_r(const time_t *timep, struct tm *result)
|
||||||
|
|
||||||
struct tm *localtime(const time_t *timer)
|
struct tm *localtime(const time_t *timer)
|
||||||
{
|
{
|
||||||
return localtime_r(timer, &g_tm);
|
static struct tm tm;
|
||||||
|
return localtime_r(timer, &tm);
|
||||||
}
|
}
|
||||||
|
|
||||||
static time_t ConvertUtc2Secs(struct tm *tm)
|
static time_t ConvertUtc2Secs(struct tm *tm)
|
||||||
|
|
Loading…
Reference in New Issue