]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
CephContext: initialize module_type in ctor
authorColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Thu, 9 Jun 2011 23:21:23 +0000 (16:21 -0700)
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Thu, 9 Jun 2011 23:21:23 +0000 (16:21 -0700)
Signed-off-by: Colin McCabe <colin.mccabe@dreamhost.com>
src/common/ceph_context.cc
src/common/ceph_context.h
src/common/common_init.cc
src/mon/MonClient.cc

index 31a9987be27a674ae435b250c933a4fae11792ab..275110e9d03663533612c7471ca80a8faeab481d 100644 (file)
@@ -25,7 +25,7 @@
 
 // FIXME
 // These variables are here temporarily to make the transition easier.
-CephContext g_ceph_context __attribute__((init_priority(103)));
+CephContext g_ceph_context __attribute__((init_priority(103))) (0);
 md_config_t *g_conf(g_ceph_context._conf);
 std::ostream *_dout(&g_ceph_context._dout);
 DoutStreambuf <char, std::basic_string<char>::traits_type> *_doss(g_ceph_context._doss);
@@ -79,10 +79,10 @@ private:
 };
 
 CephContext::
-CephContext()
+CephContext(uint32_t module_type_)
   : _doss(new DoutStreambuf <char, std::basic_string<char>::traits_type>()),
     _dout(_doss),
-    module_type(0),
+    module_type(module_type_),
     _prof_logger_conf_obs(new ProfLoggerConfObs()),
     _service_thread(NULL)
 {
@@ -163,3 +163,15 @@ join_service_thread()
   thread->join();
   delete thread;
 }
+
+uint32_t CephContext::
+get_module_type() const
+{
+  return module_type;
+}
+
+void CephContext::
+set_module_type(uint32_t module_type_)
+{
+  module_type = module_type_;
+}
index 4f3f33eb2ec42b6596070cd03604bcab13a059c4..6974cc8ac814dc1cb6663964b6cb89575439fd77 100644 (file)
@@ -16,6 +16,7 @@
 #define CEPH_CEPHCONTEXT_H
 
 #include <iostream>
+#include <stdint.h>
 
 /* Forward declarations */ 
 template <typename T, typename U>
@@ -35,14 +36,12 @@ class DoutLocker;
  */
 class CephContext {
 public:
-  CephContext();
+  CephContext(uint32_t module_type_);
   ~CephContext();
   md_config_t *_conf;
   DoutStreambuf <char, std::basic_string<char>::traits_type> *_doss;
   std::ostream _dout;
 
-  unsigned module_type;
-
   /* Start the Ceph Context's service thread */
   void start_service_thread();
 
@@ -55,10 +54,18 @@ public:
   /* Try to lock the dout lock. */
   void dout_trylock(DoutLocker *locker);
 
+  /* Get the module type (client, mon, osd, mds, etc.) */
+  uint32_t get_module_type() const;
+
+  /* Set module type (TODO: remove) */
+  void set_module_type(uint32_t module_type_);
+
 private:
   /* Stop and join the Ceph Context's service thread */
   void join_service_thread();
 
+  uint32_t module_type;
+
   md_config_obs_t *_prof_logger_conf_obs;
 
   /* libcommon service thread.
index 7e3f2e752480421a2c9575e49af4ea8f75d3c1c3..ad52a5c9760111ed7328f2ce903c61af851a3725 100644 (file)
@@ -63,7 +63,7 @@ CephContext *common_preinit(const CephInitParameters &iparams,
       conf->set_val_or_die("daemonize", "false");
       break;
   }
-  cct->module_type = iparams.module_type;
+  cct->set_module_type(iparams.module_type);
   return cct;
 }
 
index 531202c6482d68797dc73ea0b69327d007e7d554..4748c55be85569ef66b4bd2ed918a4143764b4eb 100644 (file)
@@ -349,7 +349,7 @@ int MonClient::init()
     derr << "MonClient::init(): Failed to create keyring" << dendl;
     return -EDOM;
   }
-  rotating_secrets = new RotatingKeyRing(cct->module_type, keyring);
+  rotating_secrets = new RotatingKeyRing(cct->get_module_type(), keyring);
 
   entity_name = g_conf->name;