From: Danny Al-Gaaf Date: Mon, 6 Oct 2014 10:43:59 +0000 (+0200) Subject: rados_list_parallel.cc: cleanup before return from run() X-Git-Tag: v0.88~83^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=042c5362bbc8a051479551b1ec4086b40504ea6a;p=ceph.git rados_list_parallel.cc: cleanup before return from run() 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 --- diff --git a/src/test/system/rados_list_parallel.cc b/src/test/system/rados_list_parallel.cc index 86b4bfa11246..fb4540d218ba 100644 --- a/src/test/system/rados_list_parallel.cc +++ b/src/test/system/rados_list_parallel.cc @@ -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;