]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
global: separate first half of global_init into global_pre_init
authorSage Weil <sage@inktank.com>
Sun, 30 Mar 2014 04:51:20 +0000 (21:51 -0700)
committerSage Weil <sage@inktank.com>
Sun, 30 Mar 2014 05:00:47 +0000 (22:00 -0700)
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 <sage@inktank.com>
src/global/global_init.cc
src/global/global_init.h

index fd8cd46b3707d94fd5ff13a6fab1d70012e5518a..861abfcbefbad03289bb6b5beb13f53b096c3e5e 100644 (file)
@@ -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();
index 67586e44699d48572897135763d68146e1b059c4..54c8d3d20c60a5201fe8595b4f61f827089bbd99 100644 (file)
@@ -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