From: Casey Bodley Date: Wed, 18 Nov 2015 18:37:24 +0000 (-0500) Subject: rgw: fix assert on shutdown by keeping g_ceph_context around longer X-Git-Tag: v10.1.0~354^2~190 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=edc24bf1307adcfa1e76d7e6fb7a289da1926ecc;p=ceph.git rgw: fix assert on shutdown by keeping g_ceph_context around longer RGWRealmWatcher and friends are on the stack in main(), so we can't drop the last ref on g_ceph_context until their destructors have fired. use a boost::intrusive_ptr to claim g_ceph_context's initial ref so that its destructor fires last Signed-off-by: Casey Bodley --- diff --git a/src/rgw/rgw_main.cc b/src/rgw/rgw_main.cc index 9f233292bb0f..9cc233464324 100644 --- a/src/rgw/rgw_main.cc +++ b/src/rgw/rgw_main.cc @@ -13,6 +13,8 @@ #include +#include + #include "acconfig.h" #ifdef FASTCGI_INCLUDE_DIR # include "fastcgi/fcgiapp.h" @@ -1124,6 +1126,9 @@ class RGWFrontendPauser : public RGWRealmReloader::Pauser { } }; +void intrusive_ptr_add_ref(CephContext* cct) { cct->get(); } +void intrusive_ptr_release(CephContext* cct) { cct->put(); } + /* * start up the RADOS connection and then handle HTTP messages as they come in */ @@ -1174,6 +1179,9 @@ int main(int argc, const char **argv) common_init_finish(g_ceph_context); + // claim the reference and release it after subsequent destructors have fired + boost::intrusive_ptr cct(g_ceph_context, false); + rgw_tools_init(g_ceph_context); rgw_init_resolver();