]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
save init flags to CephContext
authorYunchuan Wen <yunchuan.wen@kylin-cloud.com>
Thu, 12 Nov 2015 08:10:10 +0000 (16:10 +0800)
committerYunchuan Wen <yunchuan.wen@kylin-cloud.com>
Thu, 12 Nov 2015 08:10:51 +0000 (16:10 +0800)
The constructor of RadosClient will use CephContext,
and RadosClient.connect func will *always* use 0 as
init_flags to call common_init_finish.

So, save the init_flags to CephContex, will let
RadosClient.connect use right init_flags to finish
the cct.

Signed-off-by: Yunchuan Wen <yunchuan.wen@kylin-cloud.com>
src/common/ceph_context.cc
src/common/ceph_context.h
src/common/common_init.cc
src/common/common_init.h
src/global/global_init.cc
src/global/global_init.h

index 7383ed7fd663f9f69e2e372eda1bf489f24fbf97..6e60cf7a21658facfd5385c8aafa448141e920f4 100644 (file)
@@ -398,11 +398,12 @@ void CephContext::do_command(std::string command, cmdmap_t& cmdmap,
 }
 
 
-CephContext::CephContext(uint32_t module_type_)
+CephContext::CephContext(uint32_t module_type_, int init_flags_)
   : nref(1),
     _conf(new md_config_t()),
     _log(NULL),
     _module_type(module_type_),
+    _init_flags(init_flags_),
     _crypto_inited(false),
     _service_thread(NULL),
     _log_obs(NULL),
@@ -586,6 +587,11 @@ uint32_t CephContext::get_module_type() const
   return _module_type;
 }
 
+int CephContext::get_init_flags() const
+{
+  return _init_flags;
+}
+
 PerfCountersCollection *CephContext::get_perfcounters_collection()
 {
   return _perf_counters_collection;
index 037f2d813a2e887043653c6d64cd7c3a1994f96c..3820a2355ead4264c2404e6534a8599cff6ba668 100644 (file)
@@ -55,7 +55,7 @@ using ceph::bufferlist;
  */
 class CephContext {
 public:
-  CephContext(uint32_t module_type_);
+  CephContext(uint32_t module_type_, int init_flags_ = 0);
 
   // ref count!
 private:
@@ -86,6 +86,8 @@ public:
   /* Get the module type (client, mon, osd, mds, etc.) */
   uint32_t get_module_type() const;
 
+  int get_init_flags() const;
+
   /* Get the PerfCountersCollection of this CephContext */
   PerfCountersCollection *get_perfcounters_collection();
 
@@ -173,6 +175,8 @@ private:
 
   uint32_t _module_type;
 
+  int _init_flags;
+
   bool _crypto_inited;
 
   /* libcommon service thread.
index a580309463f812450be50d4a821c71443a5616d9..23c2e7ce7a19bc7484ea69e44f27ba1adb12f9bd 100644 (file)
@@ -39,7 +39,7 @@ CephContext *common_preinit(const CephInitParameters &iparams,
   g_code_env = code_env;
 
   // Create a configuration object
-  CephContext *cct = new CephContext(iparams.module_type);
+  CephContext *cct = new CephContext(iparams.module_type, flags);
 
   md_config_t *conf = cct->_conf;
   // add config observers here
@@ -113,10 +113,10 @@ void complain_about_parse_errors(CephContext *cct,
 
 /* Please be sure that this can safely be called multiple times by the
  * same application. */
-void common_init_finish(CephContext *cct, int flags)
+void common_init_finish(CephContext *cct)
 {
   cct->init_crypto();
 
-  if (!(flags & CINIT_FLAG_NO_DAEMON_ACTIONS))
+  if (!(cct->get_init_flags() & CINIT_FLAG_NO_DAEMON_ACTIONS))
     cct->start_service_thread();
 }
index d6aa9fa32c1b5465254bdef9a86215a92e9057b2..f48b349bf0011b4218614fce3b239090b6bbdcb7 100644 (file)
@@ -75,6 +75,6 @@ void complain_about_parse_errors(CephContext *cct,
  * libraries. The most obvious reason for this is that the threads started by
  * the Ceph libraries would be destroyed by a fork().
  */
-void common_init_finish(CephContext *cct, int flags = 0);
+void common_init_finish(CephContext *cct);
 
 #endif
index ed5d18633bedd8c848b73f7b7f30cbe5fea96210..609c7ea1e079abed9e48f38ad75e1182d0e9111a 100644 (file)
@@ -257,7 +257,7 @@ static void pidfile_remove_void(void)
   pidfile_remove();
 }
 
-int global_init_prefork(CephContext *cct, int flags)
+int global_init_prefork(CephContext *cct)
 {
   if (g_code_env != CODE_ENVIRONMENT_DAEMON)
     return -1;
@@ -279,9 +279,9 @@ int global_init_prefork(CephContext *cct, int flags)
   return 0;
 }
 
-void global_init_daemonize(CephContext *cct, int flags)
+void global_init_daemonize(CephContext *cct)
 {
-  if (global_init_prefork(cct, flags) < 0)
+  if (global_init_prefork(cct) < 0)
     return;
 
   int ret = daemon(1, 1);
@@ -293,7 +293,7 @@ void global_init_daemonize(CephContext *cct, int flags)
   }
 
   global_init_postfork_start(cct);
-  global_init_postfork_finish(cct, flags);
+  global_init_postfork_finish(cct);
 }
 
 void global_init_postfork_start(CephContext *cct)
@@ -332,13 +332,13 @@ void global_init_postfork_start(CephContext *cct)
   pidfile_write(g_conf);
 }
 
-void global_init_postfork_finish(CephContext *cct, int flags)
+void global_init_postfork_finish(CephContext *cct)
 {
   /* We only close stderr once the caller decides the daemonization
    * process is finished.  This way we can allow error messages to be
    * propagated in a manner that the user is able to see.
    */
-  if (!(flags & CINIT_FLAG_NO_CLOSE_STDERR)) {
+  if (!(cct->get_init_flags() & CINIT_FLAG_NO_CLOSE_STDERR)) {
     int ret = global_init_shutdown_stderr(cct);
     if (ret) {
       derr << "global_init_daemonize: global_init_shutdown_stderr failed with "
index 54c8d3d20c60a5201fe8595b4f61f827089bbd99..5e934a77acd11f491673f65ebcb4a1c91c9ee151 100644 (file)
@@ -46,7 +46,7 @@ void global_pre_init(std::vector < const char * > *alt_def_args,
  * to actually forking (via daemon(3)).  return 0 if we are going to proceed
  * with the fork, or -1 otherwise.
  */
-int global_init_prefork(CephContext *cct, int flags);
+int global_init_prefork(CephContext *cct);
 
 /*
  * perform all the steps that global_init_daemonize performs just after
@@ -57,7 +57,7 @@ void global_init_postfork_start(CephContext *cct);
 /*
  * close stderr, thus completing the postfork.
  */
-void global_init_postfork_finish(CephContext *cct, int flags);
+void global_init_postfork_finish(CephContext *cct);
 
 
 /*
@@ -67,7 +67,7 @@ void global_init_postfork_finish(CephContext *cct, int flags);
  * Note that this is equivalent to calling _prefork(), daemon(), and
  * _postfork.
  */
-void global_init_daemonize(CephContext *cct, int flags);
+void global_init_daemonize(CephContext *cct);
 
 /*
  * global_init_chdir changes the process directory.