From 2c4367f95d1390d857eef7f2b7f4c35d002999e2 Mon Sep 17 00:00:00 2001 From: Colin Patrick McCabe Date: Thu, 9 Jun 2011 16:21:23 -0700 Subject: [PATCH] CephContext: initialize module_type in ctor Signed-off-by: Colin McCabe --- src/common/ceph_context.cc | 18 +++++++++++++++--- src/common/ceph_context.h | 13 ++++++++++--- src/common/common_init.cc | 2 +- src/mon/MonClient.cc | 2 +- 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/common/ceph_context.cc b/src/common/ceph_context.cc index 31a9987be27a6..275110e9d0366 100644 --- a/src/common/ceph_context.cc +++ b/src/common/ceph_context.cc @@ -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 ::traits_type> *_doss(g_ceph_context._doss); @@ -79,10 +79,10 @@ private: }; CephContext:: -CephContext() +CephContext(uint32_t module_type_) : _doss(new DoutStreambuf ::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_; +} diff --git a/src/common/ceph_context.h b/src/common/ceph_context.h index 4f3f33eb2ec42..6974cc8ac814d 100644 --- a/src/common/ceph_context.h +++ b/src/common/ceph_context.h @@ -16,6 +16,7 @@ #define CEPH_CEPHCONTEXT_H #include +#include /* Forward declarations */ template @@ -35,14 +36,12 @@ class DoutLocker; */ class CephContext { public: - CephContext(); + CephContext(uint32_t module_type_); ~CephContext(); md_config_t *_conf; DoutStreambuf ::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. diff --git a/src/common/common_init.cc b/src/common/common_init.cc index 7e3f2e7524804..ad52a5c976011 100644 --- a/src/common/common_init.cc +++ b/src/common/common_init.cc @@ -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; } diff --git a/src/mon/MonClient.cc b/src/mon/MonClient.cc index 531202c6482d6..4748c55be8556 100644 --- a/src/mon/MonClient.cc +++ b/src/mon/MonClient.cc @@ -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; -- 2.39.5