Commit 95ffb27c authored by Mmanu Chaturvedi's avatar Mmanu Chaturvedi Committed by Andreas Schuh

Fix static initialization order fiasco caused by global registry lock (#215)

parent 80ebb424
......@@ -726,7 +726,6 @@ class FlagRegistry {
static FlagRegistry* global_registry_; // a singleton registry
Mutex lock_;
static Mutex global_registry_lock_;
static void InitGlobalRegistry();
......@@ -929,10 +928,10 @@ bool FlagRegistry::SetFlagLocked(CommandLineFlag* flag,
// Get the singleton FlagRegistry object
FlagRegistry* FlagRegistry::global_registry_ = NULL;
Mutex FlagRegistry::global_registry_lock_(Mutex::LINKER_INITIALIZED);
FlagRegistry* FlagRegistry::GlobalRegistry() {
MutexLock acquire_lock(&global_registry_lock_);
static Mutex lock(Mutex::LINKER_INITIALIZED);
MutexLock acquire_lock(&lock);
if (!global_registry_) {
global_registry_ = new FlagRegistry;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment