Commit a411c5f3 authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook Github Bot

Initialize the singleton-vault early in init()

Summary:
Initialize the singleton-vault early in `init()` to avoid ordering problems with other parts of `init()`.

Initialization is done by calling `SingletonVault::singleton()->registrationComplete()`. Do that before (almost) everything, in particular, before parsing args and initializing logging.

Note that this just marks it okay for singletons to be instantiated, but does not by itself instantiate any singletons. However, this is useful if, in some way, parsing args or initializing logging should happen to use singletons.

Reviewed By: andriigrynenko

Differential Revision: D4889777

fbshipit-source-id: 6817db22d38a498cd20e361fc574a146029432ec
parent a110f8da
......@@ -36,6 +36,10 @@ void init(int* argc, char*** argv, bool removeFlags) {
google::InstallFailureSignalHandler();
#endif
// Move from the registration phase to the "you can actually instantiate
// things now" phase.
folly::SingletonVault::singleton()->registrationComplete();
gflags::ParseCommandLineFlags(argc, argv, removeFlags);
auto programName = argc && argv && *argc > 0 ? (*argv)[0] : "unknown";
......@@ -44,13 +48,7 @@ void init(int* argc, char*** argv, bool removeFlags) {
#ifdef FOLLY_USE_SYMBOLIZER
// Don't use glog's DumpStackTraceAndExit; rely on our signal handler.
google::InstallFailureFunction(abort);
#endif
// Move from the registration phase to the "you can actually instantiate
// things now" phase.
folly::SingletonVault::singleton()->registrationComplete();
#ifdef FOLLY_USE_SYMBOLIZER
// Actually install the callbacks into the handler.
folly::symbolizer::installFatalSignalCallbacks();
#endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment