Chromium Code Reviews| Index: base/time/time_posix.cc |
| diff --git a/base/time/time_posix.cc b/base/time/time_posix.cc |
| index b5b8213846dbbd282b7aab63c681dc15f6a9ae33..fb1fd1fe14c382ec15d603bf66bbcbf6fe3de153 100644 |
| --- a/base/time/time_posix.cc |
| +++ b/base/time/time_posix.cc |
| @@ -21,13 +21,22 @@ |
| #include "build/build_config.h" |
| #if defined(OS_ANDROID) |
| +#include "base/lazy_instance.h" |
| #include "base/os_compat_android.h" |
| +#include "base/synchronization/lock.h" |
| #elif defined(OS_NACL) |
| #include "base/os_compat_nacl.h" |
| #endif |
| namespace { |
| +#if defined(OS_ANDROID) |
|
willchan no longer on Chromium
2014/08/05 23:14:48
No need for the OS_ANDROID stuff. This bug isn't A
bengr
2014/08/05 23:54:58
Done.
|
| +// This prevents a crash on traversing the environment global and looking up |
| +// the 'TZ' variable in libc. |
| +base::LazyInstance<base::Lock>::Leaky |
| + g_sys_time_to_time_struct_lock = LAZY_INSTANCE_INITIALIZER; |
| +#endif |
| + |
| #if !defined(OS_MACOSX) |
| // Define a system-specific SysTime that wraps either to a time_t or |
| // a time64_t depending on the host system, and associated convertion. |
| @@ -36,6 +45,9 @@ namespace { |
| typedef time64_t SysTime; |
| SysTime SysTimeFromTimeStruct(struct tm* timestruct, bool is_local) { |
| +#if defined(OS_ANDROID) |
| + base::AutoLock locked(g_sys_time_to_time_struct_lock.Get()); |
| +#endif |
| if (is_local) |
| return mktime64(timestruct); |
| else |
| @@ -43,6 +55,9 @@ SysTime SysTimeFromTimeStruct(struct tm* timestruct, bool is_local) { |
| } |
| void SysTimeToTimeStruct(SysTime t, struct tm* timestruct, bool is_local) { |
| +#if defined(OS_ANDROID) |
| + base::AutoLock locked(g_sys_time_to_time_struct_lock.Get()); |
| +#endif |
| if (is_local) |
| localtime64_r(&t, timestruct); |
| else |