]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr: pass MessageRef to monc.send_mon_message() 30449/head
authorKefu Chai <kchai@redhat.com>
Wed, 18 Sep 2019 04:46:09 +0000 (12:46 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 20 Sep 2019 10:21:56 +0000 (18:21 +0800)
less chance to leak memory

see also: https://tracker.ceph.com/issues/37884

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/mgr/DaemonServer.cc
src/mgr/MgrStandby.cc

index ba6c7f8c4a8627586eb345824857b4e137d3d55d..6722d0812ed537ce8c7daa32b477fb5f09521aeb 100644 (file)
@@ -2356,7 +2356,7 @@ void DaemonServer::send_report()
     }
   }
 
-  auto m = new MMonMgrReport();
+  auto m = ceph::make_message<MMonMgrReport>();
   py_modules.get_health_checks(&m->health_checks);
   py_modules.get_progress_events(&m->progress_events);
 
@@ -2427,7 +2427,7 @@ void DaemonServer::send_report()
   // TODO? We currently do not notify the PyModules
   // TODO: respect needs_send, so we send the report only if we are asked to do
   //       so, or the state is updated.
-  monc->send_mon_message(m);
+  monc->send_mon_message(std::move(m));
 }
 
 void DaemonServer::adjust_pgs()
index 3bcb68431c72da8b29a708a12541c9fdf4863719..465af9299ec825832f15ae8c22af289e55cad80f 100644 (file)
@@ -218,7 +218,7 @@ void MgrStandby::send_beacon()
   metadata["addrs"] = stringify(client_messenger->get_myaddrs());
   collect_sys_info(&metadata, g_ceph_context);
 
-  MMgrBeacon *m = new MMgrBeacon(monc.get_fsid(),
+  auto m = ceph::make_message<MMgrBeacon>(monc.get_fsid(),
                                 monc.get_global_id(),
                                  g_conf()->name.get_id(),
                                  addrs,
@@ -243,7 +243,7 @@ void MgrStandby::send_beacon()
     m->set_services(active_mgr->get_services());
   }
                                  
-  monc.send_mon_message(m);
+  monc.send_mon_message(std::move(m));
 }
 
 void MgrStandby::tick()