Backed out changeset d4e3fdfd5775
authorIgor Sugak <sugak@fb.com>
Thu, 30 Mar 2017 01:14:16 +0000 (18:14 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Thu, 30 Mar 2017 01:21:50 +0000 (18:21 -0700)
Summary:
https://our.intern.facebook.com/intern/sevmanager/view/s/145809/?hc_location=ufi

```
hg backout d4e3fdfd57750c8dcabdb4c01ab3b528c4818624
```

Reviewed By: lbrandy

Differential Revision: D4799568

fbshipit-source-id: 76366040702e68becc7e245d7ce15832f933e10e

folly/Singleton-inl.h
folly/Singleton.cpp
folly/Singleton.h

index 40c7a27af3c098d0a0c0e9b9f11b4c873cb1a1b4..e6675165a8d8b15b1ef3d593d801d1df8a6e2b03 100644 (file)
@@ -228,17 +228,6 @@ void SingletonHolder<T>::createInstance() {
   creating_thread_.store(std::this_thread::get_id(), std::memory_order_release);
 
   auto state = vault_.state_.rlock();
-  if (vault_.type_ != SingletonVault::Type::Relaxed &&
-      !state->registrationComplete) {
-    auto stack_trace_getter = SingletonVault::stackTraceGetter().load();
-    auto stack_trace = stack_trace_getter ? stack_trace_getter() : "";
-    if (!stack_trace.empty()) {
-      stack_trace = "Stack trace:\n" + stack_trace;
-    }
-
-    LOG(FATAL) << "Singleton " << type().name() << " requested before "
-               << "registrationComplete() call. " << stack_trace;
-  }
   if (state->state == SingletonVault::SingletonVaultState::Quiescing) {
     return;
   }
index 07ec2666bad7cee294f5c097f9bc80b2289e6546..67e6fd811cab7bac48635c1d628a53826df45ac4 100644 (file)
 
 #include <folly/Singleton.h>
 
-#ifndef _WIN32
-#include <dlfcn.h>
-#endif
-
 #include <atomic>
 #include <cstdio>
 #include <cstdlib>
 
 #include <folly/ScopeGuard.h>
 
-#if !defined(_WIN32) && !defined(__APPLE__) && !defined(__ANDROID__)
-static void hs_init_weak(int* argc, char** argv[])
-    __attribute__((__weakref__("hs_init")));
-#endif
-
 namespace folly {
 
-SingletonVault::Type SingletonVault::defaultVaultType() {
-#if !defined(_WIN32) && !defined(__APPLE__) && !defined(__ANDROID__)
-  bool isPython = dlsym(RTLD_DEFAULT, "Py_Main");
-  bool isHaskell = &::hs_init_weak || dlsym(RTLD_DEFAULT, "hs_init");
-  bool isJVM = dlsym(RTLD_DEFAULT, "JNI_GetCreatedJavaVMs");
-  bool isD = dlsym(RTLD_DEFAULT, "_d_run_main");
-
-  return (isPython || isHaskell || isJVM || isD) ? Type::Relaxed : Type::Strict;
-#else
-  return Type::Relaxed;
-#endif
-}
-
 namespace detail {
 
 [[noreturn]] void singletonWarnDoubleRegistrationAndAbort(
index e8344cef55348bba3375de28b91e4b414f846ffd..2c699e4793d7224c54a45b6acc5dbb9cdeec0962 100644 (file)
@@ -358,9 +358,7 @@ class SingletonVault {
     }
   };
 
-  static Type defaultVaultType();
-
-  explicit SingletonVault(Type type = defaultVaultType()) : type_(type) {}
+  explicit SingletonVault(Type type = Type::Strict) : type_(type) {}
 
   // Destructor is only called by unit tests to check destroyInstances.
   ~SingletonVault();