]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
st_rados_create_pool.cc: cleanup before return from run()
authorDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Thu, 4 Sep 2014 11:01:11 +0000 (13:01 +0200)
committerDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Thu, 4 Sep 2014 11:01:11 +0000 (13:01 +0200)
CID 739605 (#1 of 1): Resource leak (RESOURCE_LEAK)
 leaked_storage: Variable io_ctx going out of scope leaks the
 storage it points to.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
src/test/system/st_rados_create_pool.cc

index 6bbe628ed17d7134166f683d66f8eb5cb6734383..78083c7732ef8e8fc0d319b4117550db64819a69 100644 (file)
@@ -64,6 +64,7 @@ StRadosCreatePool::
 int StRadosCreatePool::
 run()
 {
+  int ret_val = 0;
   rados_t cl;
   RETURN1_IF_NONZERO(rados_create(&cl, NULL));
   rados_conf_parse_argv(cl, m_argc, m_argv);
@@ -93,12 +94,15 @@ run()
     int ret = rados_write(io_ctx, oid, buf.c_str(), buf.size(), 0);
     if (ret != 0) {
       printf("%s: rados_write error %d\n", get_id_str(), ret);
-      return ret;
+      ret_val = ret;
+      goto out;
     }
     if (((i % 25) == 0) || (i == m_num_objects - 1)) {
       printf("%s: created object %d...\n", get_id_str(), i);
     }
   }
+
+out:
   printf("%s: finishing.\n", get_id_str());
   if (m_pool_setup_sem)
     m_pool_setup_sem->post();
@@ -106,5 +110,5 @@ run()
     m_close_create_pool->wait();
   rados_ioctx_destroy(io_ctx);
   rados_shutdown(cl);
-  return 0;
+  return ret_val;
 }