From: Sage Weil Date: Fri, 28 Sep 2012 15:09:09 +0000 (-0700) Subject: cephtool: fix resource leak X-Git-Tag: v0.54~187^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=70e35ba9b1a9ea8fc21bacc46967d74656b57a30;p=ceph.git cephtool: fix resource leak CID 717124: Resource leak (RESOURCE_LEAK) At (17): Variable "m" going out of scope leaks the storage it points to. Signed-off-by: Sage Weil --- diff --git a/src/tools/common.cc b/src/tools/common.cc index 1c1a3bc397c7..c5005689822d 100644 --- a/src/tools/common.cc +++ b/src/tools/common.cc @@ -134,11 +134,6 @@ static void send_command(CephToolCtx *ctx) if (!ctx->concise) *ctx->log << ceph_clock_now(g_ceph_context) << " " << pending_target << " <- " << pending_cmd << std::endl; - MCommand *m = new MCommand(ctx->mc.monmap.fsid); - m->cmd = pending_cmd; - m->set_data(pending_bl); - m->set_tid(++pending_tid); - if (pending_tell_pgid) { // pick target osd vector osds; @@ -172,10 +167,14 @@ static void send_command(CephToolCtx *ctx) reply_rc = -ESRCH; reply = true; } else { - if (!ctx->concise) *ctx->log << ceph_clock_now(g_ceph_context) << " " << pending_target << " <- " << pending_cmd << std::endl; + MCommand *m = new MCommand(ctx->mc.monmap.fsid); + m->cmd = pending_cmd; + m->set_data(pending_bl); + m->set_tid(++pending_tid); + command_con = messenger->get_connection(osdmap->get_inst(n)); messenger->send_message(m, command_con);