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

Unified Diff: third_party/mojo/src/mojo/edk/embedder/entrypoints.cc

Issue 1663693002: Re-land: Fix race in UseNewEDK(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 | « build/sanitizers/tsan_suppressions.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/mojo/src/mojo/edk/embedder/entrypoints.cc
diff --git a/third_party/mojo/src/mojo/edk/embedder/entrypoints.cc b/third_party/mojo/src/mojo/edk/embedder/entrypoints.cc
index 3d30deb466b1d8438e8ccc8b37e35313c57a35bf..992bbd66f7c2249e3c86bcbe243006024bfc3679 100644
--- a/third_party/mojo/src/mojo/edk/embedder/entrypoints.cc
+++ b/third_party/mojo/src/mojo/edk/embedder/entrypoints.cc
@@ -5,6 +5,7 @@
#include "../../../../../../mojo/edk/embedder/embedder_internal.h"
#include "../../../../../../mojo/edk/system/core.h"
#include "base/command_line.h"
+#include "base/lazy_instance.h"
#include "mojo/public/c/system/buffer.h"
#include "mojo/public/c/system/data_pipe.h"
#include "mojo/public/c/system/functions.h"
@@ -17,17 +18,25 @@ using mojo::embedder::internal::g_core;
using mojo::system::MakeUserPointer;
namespace {
-bool UseNewEDK() {
- static bool checked = false;
- static bool use_new = false;
- if (!checked) {
+
+struct UseNewEDKChecker {
+ UseNewEDKChecker() {
use_new = base::CommandLine::ForCurrentProcess()->HasSwitch("use-new-edk");
- checked = true;
}
- return use_new;
-}
+
+ bool use_new;
+};
+
+// This is Leaky to avoid a recursive lock acquisition in AtExitManager.
+base::LazyInstance<UseNewEDKChecker>::Leaky g_use_new_checker =
+ LAZY_INSTANCE_INITIALIZER;
+
+bool UseNewEDK() {
+ return g_use_new_checker.Get().use_new;
}
+} // namespace
+
// Definitions of the system functions.
extern "C" {
MojoTimeTicks MojoGetTimeTicksNow() {
« no previous file with comments | « build/sanitizers/tsan_suppressions.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698