]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cephtool: fix resource leak
authorSage Weil <sage@inktank.com>
Fri, 28 Sep 2012 15:09:09 +0000 (08:09 -0700)
committerSage Weil <sage@inktank.com>
Fri, 28 Sep 2012 20:18:06 +0000 (13:18 -0700)
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 <sage@inktank.com>
src/tools/common.cc

index 1c1a3bc397c78432b4a6ca1adff272b854dc4d88..c5005689822d6cfdbbed0864006a24ac3e861534 100644 (file)
@@ -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<int> 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);