Allocate stacks with guard pages by default
[folly.git] / folly / Singleton.cpp
index c2a8afdef314714f4fd4d33236048291503e2447..8e9cd99b0763138bd8eb7c61819da5c293a61703 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2015 Facebook, Inc.
+ * Copyright 2016 Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -96,7 +96,6 @@ void SingletonVault::addEagerInitSingleton(detail::SingletonHolderBase* entry) {
 }
 
 void SingletonVault::registrationComplete() {
-  RequestContext::saveContext();
   std::atexit([](){ SingletonVault::singleton()->destroyInstances(); });
 
   RWSpinLock::WriteHolder wh(&stateMutex_);
@@ -214,7 +213,9 @@ void SingletonVault::reenableInstances() {
 }
 
 void SingletonVault::scheduleDestroyInstances() {
-  RequestContext::saveContext();
+  // Add a dependency on folly::ThreadLocal to make sure all its static
+  // singletons are initalized first.
+  threadlocal_detail::StaticMeta<void>::instance();
 
   class SingletonVaultDestructor {
    public: