]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librados: drop io_ctx_impl on ioctx_create/create2
authorVenky Shankar <vshankar@redhat.com>
Wed, 9 Nov 2016 11:28:06 +0000 (16:58 +0530)
committerVenky Shankar <vshankar@redhat.com>
Sun, 20 Nov 2016 15:51:50 +0000 (21:21 +0530)
close() was never called for the passed in IoCtx which
could probably result in an IoCtx leak if the original
IoCtx was a valid pool context allocated earlier.

Its kind of better to do it here rather than to leave
the destruction on the caller for better (or cleaner)
common case handling.

Signed-off-by: Venky Shankar <vshankar@redhat.com>
src/librados/librados.cc
src/test/librados_test_stub/LibradosTestStub.cc

index 0991de4e9190068e17b3a3030dd49c24f04b9ec4..44d6e6b287a97adfa711898ec07eba0dcb8d81c4 100644 (file)
@@ -2413,6 +2413,7 @@ int librados::Rados::ioctx_create(const char *name, IoCtx &io)
   int ret = rados_ioctx_create((rados_t)client, name, &p);
   if (ret)
     return ret;
+  io.close();
   io.io_ctx_impl = (IoCtxImpl*)p;
   return 0;
 }
@@ -2423,6 +2424,7 @@ int librados::Rados::ioctx_create2(int64_t pool_id, IoCtx &io)
   int ret = rados_ioctx_create2((rados_t)client, pool_id, &p);
   if (ret)
     return ret;
+  io.close();
   io.io_ctx_impl = (IoCtxImpl*)p;
   return 0;
 }
index e996adc71eb45112728cbbd20fc84214604fee08..005c576bc8bd0121a14cb0a77bc997a071918dd8 100644 (file)
@@ -906,6 +906,8 @@ int Rados::ioctx_create(const char *name, IoCtx &io) {
   if (ret) {
     return ret;
   }
+
+  io.close();
   io.io_ctx_impl = reinterpret_cast<IoCtxImpl*>(p);
   return 0;
 }
@@ -917,6 +919,8 @@ int Rados::ioctx_create2(int64_t pool_id, IoCtx &io)
   if (ret) {
     return ret;
   }
+
+  io.close();
   io.io_ctx_impl = reinterpret_cast<IoCtxImpl*>(p);
   return 0;
 }