Summary:
This also adds a dependency from all folly::Singletons on RequestContext. Better fix would probaly be to switch RequestContext to be managed by folly::Singleton, however that would require us to switch all singletons which use it to be folly::Singletons too.
Facebook:
Making sure we initialize SR singletons when OBCClient singleton is created, so that SR is destoyed after OBCClient.
Test Plan:
fbconfig -r --sanitize=address --platform-all=gcc-4.8.1-glibc-2.17 dragon/
fbmake runtests
Reviewed By: meyering@fb.com, davejwatson@fb.com
Subscribers: trunkagent, folly-diffs@, meyering
FB internal diff:
D1796847
Tasks:
5986816
Signature: t1:
1796847:
1421954531:
e9ec177d5289a33c12fe0947426d89963c8e262c
}
void SingletonVault::scheduleDestroyInstances() {
+ RequestContext::getStaticContext();
+
class SingletonVaultDestructor {
public:
~SingletonVaultDestructor() {
#include <folly/Hash.h>
#include <folly/Memory.h>
#include <folly/RWSpinLock.h>
+#include <folly/io/async/Request.h>
#include <algorithm>
#include <vector>
// Mark registration is complete; no more singletons can be
// registered at this point.
void registrationComplete() {
+ RequestContext::getStaticContext();
std::atexit([](){ SingletonVault::singleton()->destroyInstances(); });
RWSpinLock::WriteHolder wh(&stateMutex_);