diff options
author | Mmanu Chaturvedi <m-chaturvedi@users.noreply.github.com> | 2017-05-12 15:11:28 -0600 |
---|---|---|
committer | Andreas Schuh <andreas.schuh.84@gmail.com> | 2017-05-12 22:11:28 +0100 |
commit | 95ffb27c9c7496ede1409e042571054c70cb9519 (patch) | |
tree | 867529698c5f3fb6e722ba798223fba36520bc8a | |
parent | 80ebb424a5c1dfe232242b9bb572047318382377 (diff) | |
download | gflags-95ffb27c9c7496ede1409e042571054c70cb9519.tar.gz gflags-95ffb27c9c7496ede1409e042571054c70cb9519.tar.bz2 gflags-95ffb27c9c7496ede1409e042571054c70cb9519.zip |
Fix static initialization order fiasco caused by global registry lock (#215)
-rw-r--r-- | src/gflags.cc | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/gflags.cc b/src/gflags.cc index 921b4f9..08e4f45 100644 --- a/src/gflags.cc +++ b/src/gflags.cc @@ -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; } |