diff options
author | Kefu Chai <kchai@redhat.com> | 2016-11-15 07:21:03 +0100 |
---|---|---|
committer | Kefu Chai <kchai@redhat.com> | 2016-11-24 15:38:28 +0100 |
commit | cb1cda96713b2ec0f6418c4cbe3d964c2020729c (patch) | |
tree | 2172eb81f79a3a93c1b3d1b74f31bfadeeb0a216 /src/test/test_snap_mapper.cc | |
parent | crushtool: s/exit(EXIT_FAILURE)/return EXIT_FAILURE/ (diff) | |
download | ceph-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/test/test_snap_mapper.cc')
-rw-r--r-- | src/test/test_snap_mapper.cc | 16 |
1 files changed, 2 insertions, 14 deletions
diff --git a/src/test/test_snap_mapper.cc b/src/test/test_snap_mapper.cc index 53f1d292897..51244091397 100644 --- a/src/test/test_snap_mapper.cc +++ b/src/test/test_snap_mapper.cc @@ -4,15 +4,14 @@ #include <set> #include <boost/scoped_ptr.hpp> #include <sys/types.h> +#include <cstdlib> #include "include/buffer.h" #include "common/map_cacher.hpp" #include "osd/SnapMapper.h" -#include "global/global_init.h" -#include "common/ceph_argparse.h" +#include "test/unit.h" #include "gtest/gtest.h" -#include "stdlib.h" using namespace std; @@ -660,14 +659,3 @@ TEST_F(SnapMapperTest, MultiPG) { init(50); run(); } - -int main(int argc, char **argv) -{ - vector<const char*> args; - argv_to_vec(argc, (const char **)argv, args); - - global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0); - common_init_finish(g_ceph_context); - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} |