diff options
-rw-r--r-- | base/at_exit.cc | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/base/at_exit.cc b/base/at_exit.cc index e467c5d..b7ab0a7 100644 --- a/base/at_exit.cc +++ b/base/at_exit.cc @@ -12,13 +12,19 @@ namespace base { // Keep a stack of registered AtExitManagers. We always operate on the most -// recent, and we should never have more than one outside of testing, when we -// use the shadow version of the constructor. We don't protect this for -// thread-safe access, since it will only be modified in testing. +// recent, and we should never have more than one outside of testing (for a +// statically linked version of this library). Testing may use the shadow +// version of the constructor, and if we are building a dynamic library we may +// end up with multiple AtExitManagers on the same process. We don't protect +// this for thread-safe access, since it will only be modified in testing. static AtExitManager* g_top_manager = NULL; -AtExitManager::AtExitManager() : next_manager_(NULL) { +AtExitManager::AtExitManager() : next_manager_(g_top_manager) { +// If multiple modules instantiate AtExitManagers they'll end up living in this +// module... they have to coexist. +#if !defined(BASE_DLL) DCHECK(!g_top_manager); +#endif g_top_manager = this; } |