]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librados: simplify cct refcounting
authorSage Weil <sage@inktank.com>
Wed, 11 Jul 2012 16:04:50 +0000 (09:04 -0700)
committerSage Weil <sage@inktank.com>
Wed, 11 Jul 2012 16:04:50 +0000 (09:04 -0700)
get() in ctor, put() in dtor.

Signed-off-by: Sage Weil <sage@inktank.com>
src/librados/RadosClient.cc
src/librados/librados.cc

index ecf923f751155f8b5764e0168ff51c30fe691350..63813ffe2aa516ba3a211d7ac5b7d3590d69797f 100644 (file)
@@ -57,7 +57,7 @@ bool librados::RadosClient::ms_get_authorizer(int dest_type,
 
 librados::RadosClient::RadosClient(CephContext *cct_)
   : Dispatcher(cct_),
-    cct(cct_),
+    cct(cct_->get()),
     conf(cct_->_conf),
     state(DISCONNECTED),
     monclient(cct_),
index 48fd5dc255bd417e44851c8928aafe2d7eb595ea..a50c67b631443ca6c903ca1b32ae0da4871920ea 100644 (file)
@@ -1287,6 +1287,8 @@ extern "C" int rados_create(rados_t *pcluster, const char * const id)
 
   librados::RadosClient *radosp = new librados::RadosClient(cct);
   *pcluster = (void *)radosp;
+
+  cct->put();
   return 0;
 }
 
@@ -1297,7 +1299,7 @@ extern "C" int rados_create(rados_t *pcluster, const char * const id)
 extern "C" int rados_create_with_context(rados_t *pcluster, rados_config_t cct_)
 {
   CephContext *cct = (CephContext *)cct_;
-  librados::RadosClient *radosp = new librados::RadosClient(cct->get());
+  librados::RadosClient *radosp = new librados::RadosClient(cct);
   *pcluster = (void *)radosp;
   return 0;
 }