Skip to content

Commit

Permalink
librados: postpone cct deletion
Browse files Browse the repository at this point in the history
when `debug refs` is enabled, RefCountedObject::put() prints log using
cct, but RadosClient relinquishes the reference to cct too early, so its
when its `RefCountedObject` member variables print log when they are
destructed, the cct is freed. so we need postpone destructure of it
after all other RefCountedObject member variables are destroyed.

Signed-off-by: Kefu Chai <kchai@redhat.com>
  • Loading branch information
tchaikov committed Oct 26, 2016
1 parent 0919de2 commit 1434316
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/librados/RadosClient.cc
Expand Up @@ -65,6 +65,7 @@ bool librados::RadosClient::ms_get_authorizer(int dest_type,

librados::RadosClient::RadosClient(CephContext *cct_)
: Dispatcher(cct_->get()),
cct_deleter{cct_, [](CephContext *p) {p->put();}},
conf(cct_->_conf),
state(DISCONNECTED),
monclient(cct_),
Expand Down Expand Up @@ -431,7 +432,6 @@ librados::RadosClient::~RadosClient()
delete messenger;
if (objecter)
delete objecter;
cct->put();
cct = NULL;
}

Expand Down
3 changes: 3 additions & 0 deletions src/librados/RadosClient.h
Expand Up @@ -37,6 +37,9 @@ class AioCompletionImpl;

class librados::RadosClient : public Dispatcher
{
std::unique_ptr<CephContext,
std::function<void(CephContext*)> > cct_deleter;

public:
using Dispatcher::cct;
md_config_t *conf;
Expand Down

0 comments on commit 1434316

Please sign in to comment.