From: Karol Mroz Date: Tue, 9 Feb 2016 22:09:29 +0000 (-0800) Subject: global_init: add run_pre_init argument to function signature X-Git-Tag: v10.1.0~157^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f50c332bcbb0d04f8768c3fff00c5fb3fb24e176;p=ceph.git global_init: add run_pre_init argument to function signature Allows running the global_pre_init() separately in order to parse config options prior to invoking global_init(). Signed-off-by: Karol Mroz --- diff --git a/src/global/global_init.cc b/src/global/global_init.cc index 18ad76e433f6..bd5f6069a6c3 100644 --- a/src/global/global_init.cc +++ b/src/global/global_init.cc @@ -66,8 +66,6 @@ void global_pre_init(std::vector < const char * > *alt_def_args, int flags, const char *data_dir_option) { - // You can only call global_init once. - assert(!g_ceph_context); std::string conf_file_list; std::string cluster = ""; CephInitParameters iparams = ceph_argparse_early_args(args, module_type, flags, @@ -116,10 +114,19 @@ 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, - const char *data_dir_option) + const char *data_dir_option, bool run_pre_init) { - global_pre_init(alt_def_args, args, module_type, code_env, flags, - data_dir_option); + // Ensure we're not calling the global init functions multiple times. + static bool first_run = true; + if (run_pre_init) { + // We will run pre_init from here (default). + assert(!g_ceph_context && first_run); + global_pre_init(alt_def_args, args, module_type, code_env, flags); + } else { + // Caller should have invoked pre_init manually. + assert(g_ceph_context && first_run); + } + first_run = false; // signal stuff int siglist[] = { SIGPIPE, 0 }; diff --git a/src/global/global_init.h b/src/global/global_init.h index 0e27d43d55f1..79c0bad5c7e5 100644 --- a/src/global/global_init.h +++ b/src/global/global_init.h @@ -35,7 +35,8 @@ void global_init(std::vector < const char * > *alt_def_args, uint32_t module_type, code_environment_t code_env, int flags, - const char *data_dir_option = 0); + const char *data_dir_option = 0, + bool run_pre_init = true); // just the first half; enough to get config parsed but doesn't start up the // cct or log.