summaryrefslogtreecommitdiffstats
path: root/src/ceph_mgr.cc
diff options
context:
space:
mode:
authorKefu Chai <kchai@redhat.com>2016-11-15 07:21:03 +0100
committerKefu Chai <kchai@redhat.com>2016-11-24 15:38:28 +0100
commitcb1cda96713b2ec0f6418c4cbe3d964c2020729c (patch)
tree2172eb81f79a3a93c1b3d1b74f31bfadeeb0a216 /src/ceph_mgr.cc
parentcrushtool: s/exit(EXIT_FAILURE)/return EXIT_FAILURE/ (diff)
downloadceph-cb1cda96713b2ec0f6418c4cbe3d964c2020729c.tar.xz
ceph-cb1cda96713b2ec0f6418c4cbe3d964c2020729c.zip
common,test: g_ceph_context->put() upon return
prior to this change, global_init() could create a new CephContext and assign it to g_ceph_context. it's our responsibilty to release the CephContext explicitly using cct->put() before the application quits. but sometimes, we fail to do so. in this change, global_init() will return an intrusive_ptr<CephContext>, which calls `g_ceph_context->put()` in its dtor. this ensures that the CephContext is always destroyed before main() returns. so the log is flushed before _log_exp_length is destroyed. there are two cases where global_pre_init() is called directly. - ceph_conf.cc: g_ceph_context->put() will be called by an intrusive_ptr<> deleter. - rgw_main.cc: global_init() is called later on on the success code path, so it will be taken care of. Fixes: http://tracker.ceph.com/issues/17762 Signed-off-by: Kefu Chai <kchai@redhat.com>
Diffstat (limited to 'src/ceph_mgr.cc')
-rw-r--r--src/ceph_mgr.cc5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/ceph_mgr.cc b/src/ceph_mgr.cc
index 9365fb83fd1..acdddec194e 100644
--- a/src/ceph_mgr.cc
+++ b/src/ceph_mgr.cc
@@ -35,8 +35,9 @@ int main(int argc, const char **argv)
argv_to_vec(argc, argv, args);
env_to_vec(args);
- global_init(NULL, args, CEPH_ENTITY_TYPE_MGR, CODE_ENVIRONMENT_DAEMON, 0,
- "mgr_data");
+ auto cct = global_init(NULL, args, CEPH_ENTITY_TYPE_MGR,
+ CODE_ENVIRONMENT_DAEMON, 0,
+ "mgr_data");
// For consumption by KeyRing::from_ceph_context in MonClient
g_conf->set_val("keyring", "$mgr_data/keyring", false);