RefCountedObject::put() prints log using cct, but RadosClient
relinquishes the reference to cct too early, so when its
`RefCountedObject` member variables print log when they are
destructed, the cct is already freed. hence we have a segfault.
to address this problem, we need postpone destructure of it after all
other RefCountedObject member variables are destroyed.
Signed-off-by: Kefu Chai <kchai@redhat.com>
librados::RadosClient::RadosClient(CephContext *cct_)
: Dispatcher(cct_->get()),
+ cct_deleter{cct_, [](CephContext *p) {p->put();}},
conf(cct_->_conf),
state(DISCONNECTED),
monclient(cct_),
delete messenger;
if (objecter)
delete objecter;
- cct->put();
cct = NULL;
}
class librados::RadosClient : public Dispatcher
{
+ std::unique_ptr<CephContext,
+ std::function<void(CephContext*)> > cct_deleter;
+
public:
using Dispatcher::cct;
md_config_t *conf;