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>
(cherry picked from commit
cb1cda96713b2ec0f6418c4cbe3d964c2020729c)
Conflicts:
src/ceph_fuse.cc
src/ceph_mgr.cc
src/global/global_init.cc
src/rgw/rgw_main.cc
src/test/compressor/test_compression.cc
src/test/compressor/test_compression_plugin.cc
src/test/compressor/test_compression_plugin_snappy.cc
src/test/compressor/test_compression_plugin_zlib.cc
src/test/compressor/test_compression_snappy.cc
src/test/compressor/test_compression_zlib.cc
src/test/erasure-code/TestErasureCode.cc
src/test/erasure-code/TestErasureCodeExample.cc
src/test/erasure-code/TestErasureCodeIsa.cc
src/test/erasure-code/TestErasureCodeJerasure.cc
src/test/erasure-code/TestErasureCodeLrc.cc
src/test/erasure-code/TestErasureCodePlugin.cc
src/test/erasure-code/TestErasureCodePluginIsa.cc
src/test/erasure-code/TestErasureCodePluginJerasure.cc
src/test/erasure-code/TestErasureCodePluginLrc.cc
src/test/erasure-code/TestErasureCodePluginShec.cc
src/test/erasure-code/TestErasureCodeShec.cc
src/test/erasure-code/TestErasureCodeShec_thread.cc
src/test/fio/fio_ceph_objectstore.cc
src/test/librados/misc.cc
src/test/mon/PGMap.cc
src/test/msgr/test_async_networkstack.cc
src/test/msgr/test_userspace_event.cc
src/test/objectstore/Allocator_test.cc
src/test/objectstore/BitAllocator_test.cc
src/test/objectstore/test_bluefs.cc
src/test/objectstore/test_bluestore_types.cc
src/test/objectstore/test_memstore_clone.cc
src/test/osd/TestPGLog.cc
src/test/rgw/test_http_manager.cc
src/test/rgw/test_rgw_compression.cc
src/test/test_mempool.cc
src/tools/rados/rados.cc