]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rados_list_parallel.cc: cleanup before return from run()
authorDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Mon, 6 Oct 2014 10:43:59 +0000 (12:43 +0200)
committerDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Wed, 8 Oct 2014 20:56:22 +0000 (22:56 +0200)
Fix for another case of:

CID 717112 (#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/rados_list_parallel.cc

index 86b4bfa11246abad444fc030ab74903827531e2a..fb4540d218ba52ed03db0d559fb74348b7160081 100644 (file)
@@ -58,6 +58,7 @@ public:
 
   int run(void)
   {
+    int ret_val = 0;
     rados_t cl;
     RETURN1_IF_NONZERO(rados_create(&cl, NULL));
     rados_conf_parse_argv(cl, m_argc, m_argv);
@@ -90,7 +91,8 @@ public:
       for (int i = 0; i < r; ++i)
        ++d;
       if (d == to_delete.end()) {
-       return -EDOM;
+       ret_val = -EDOM;
+       goto out;
       }
       std::string oid(d->second);
       to_delete.erase(d);
@@ -98,7 +100,8 @@ public:
       if (ret != 0) {
        printf("%s: rados_remove(%s) failed with error %d\n",
               get_id_str(), oid.c_str(), ret);
-       return ret;
+       ret_val = ret;
+       goto out;
       }
       ++removed;
       if ((removed % 25) == 0) {
@@ -112,10 +115,11 @@ public:
 
     printf("%s: removed %d objects\n", get_id_str(), removed);
 
+out:
     rados_ioctx_destroy(io_ctx);
     rados_shutdown(cl);
 
-    return 0;
+    return ret_val;
   }
 private:
   std::string m_pool_name;