From 98551fc7a6717515bce6175bd90d4c96ffa3ddaa Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Sat, 29 Mar 2014 21:51:20 -0700 Subject: [PATCH] global: separate first half of global_init into global_pre_init The pre_init now captures enough to create the g_ceph_context and parse and initialize the in-memory config. However, we don't - fiddle with signal handlers - init lockdep - call config observers (which starts up logging) Signed-off-by: Sage Weil --- src/global/global_init.cc | 23 ++++++++++++++++------- src/global/global_init.h | 12 ++++++++++-- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/global/global_init.cc b/src/global/global_init.cc index fd8cd46b3707d..861abfcbefbad 100644 --- a/src/global/global_init.cc +++ b/src/global/global_init.cc @@ -56,8 +56,10 @@ static const char* c_str_or_null(const std::string &str) return str.c_str(); } -void global_init(std::vector < const char * > *alt_def_args, std::vector < const char* >& args, - uint32_t module_type, code_environment_t code_env, int flags) +void global_pre_init(std::vector < const char * > *alt_def_args, + std::vector < const char* >& args, + uint32_t module_type, code_environment_t code_env, + int flags) { // You can only call global_init once. assert(!g_ceph_context); @@ -104,10 +106,17 @@ void global_init(std::vector < const char * > *alt_def_args, std::vector < const // Expand metavariables. Invoke configuration observers. conf->apply_changes(NULL); - g_lockdep = cct->_conf->lockdep; - // Now we're ready to complain about config file parse errors complain_about_parse_errors(cct, &parse_errors); +} + +void global_init(std::vector < const char * > *alt_def_args, + std::vector < const char* >& args, + uint32_t module_type, code_environment_t code_env, int flags) +{ + global_pre_init(alt_def_args, args, module_type, code_env, flags); + + g_lockdep = g_ceph_context->_conf->lockdep; // signal stuff int siglist[] = { SIGPIPE, 0 }; @@ -131,13 +140,13 @@ void global_init(std::vector < const char * > *alt_def_args, std::vector < const if (g_lockdep) { dout(1) << "lockdep is enabled" << dendl; - lockdep_register_ceph_context(cct); + lockdep_register_ceph_context(g_ceph_context); } - register_assert_context(cct); + register_assert_context(g_ceph_context); // call all observers now. this has the side-effect of configuring // and opening the log file immediately. - conf->call_all_observers(); + g_conf->call_all_observers(); if (code_env == CODE_ENVIRONMENT_DAEMON && !(flags & CINIT_FLAG_NO_DAEMON_ACTIONS)) output_ceph_version(); diff --git a/src/global/global_init.h b/src/global/global_init.h index 67586e44699d4..54c8d3d20c60a 100644 --- a/src/global/global_init.h +++ b/src/global/global_init.h @@ -30,8 +30,16 @@ class CephContext; * daemons and utility programs need to call. It takes care of a lot of * initialization, including setting up g_ceph_context. */ -void global_init(std::vector < const char * > *alt_def_args, std::vector < const char* >& args, - uint32_t module_type, code_environment_t code_env, int flags); +void global_init(std::vector < const char * > *alt_def_args, + std::vector < const char* >& args, + uint32_t module_type, code_environment_t code_env, int flags); + +// just the first half; enough to get config parsed but doesn't start up the +// cct or log. +void global_pre_init(std::vector < const char * > *alt_def_args, + std::vector < const char* >& args, + uint32_t module_type, code_environment_t code_env, + int flags); /* * perform all of the steps that global_init_daemonize performs just prior -- 2.39.5