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 <kmroz@suse.com>
This commit is contained in:
Karol Mroz 2016-02-09 14:09:29 -08:00
parent c218c53d1a
commit f50c332bcb
2 changed files with 14 additions and 6 deletions

View File

@ -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 };

View File

@ -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.