Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(229)

Unified Diff: runtime/vm/os_macos.cc

Issue 2854303005: Fixes issue 29539 with the workaround of initializing libnotify early by calling localtime_r in OS:… (Closed)
Patch Set: assss Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/os_macos.cc
diff --git a/runtime/vm/os_macos.cc b/runtime/vm/os_macos.cc
index d4ff67912c6b0b7b1697b730a9d6f83e3cdfdc6a..9e9241c67746bde19227db25e31fb843702c3d2e 100644
--- a/runtime/vm/os_macos.cc
+++ b/runtime/vm/os_macos.cc
@@ -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;
+ }
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698