Fixes issue 29539 with the workaround of initializing libnotify early by calling localtime_r in OS::InitOnce().

BUG=Fixes #29539
R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2854303005 .
This commit is contained in:
Siva Annamalai 2017-05-03 18:24:37 -07:00
parent af7f15e633
commit 9b1412031b

View file

@ -423,6 +423,21 @@ void OS::InitOnce() {
static bool init_once_called = false;
ASSERT(init_once_called == false);
init_once_called = true;
// See https://github.com/dart-lang/sdk/issues/29539
// This is a workaround for a macos bug, we eagerly call localtime_r so that
// libnotify is initialized early before any fork happens.
struct timeval tv;
if (gettimeofday(&tv, NULL) < 0) {
FATAL1("gettimeofday returned an error (%s)\n", strerror(errno));
return;
}
tm decomposed;
struct tm* error_code = localtime_r(&(tv.tv_sec), &decomposed);
if (error_code == NULL) {
FATAL1("localtime_r returned an error (%s)\n", strerror(errno));
return;
}
}