]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
global_init: add run_pre_init argument to function signature
authorKarol Mroz <kmroz@suse.com>
Tue, 9 Feb 2016 22:09:29 +0000 (14:09 -0800)
committerKarol Mroz <kmroz@suse.com>
Thu, 10 Mar 2016 08:33:16 +0000 (09:33 +0100)
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>
src/global/global_init.cc
src/global/global_init.h

index 18ad76e433f68a14ac78c0a24d2513e7a2f5954b..bd5f6069a6c3602ccbebddd7658bba3cef66cbef 100644 (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 };
index 0e27d43d55f1aacbc78b75525487a8bee0606863..79c0bad5c7e5d8541d85177276733cc10acaeb7d 100644 (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.