From: Kefu Chai Date: Wed, 18 Sep 2019 04:46:09 +0000 (+0800) Subject: mgr: pass MessageRef to monc.send_mon_message() X-Git-Tag: v15.1.0~1475^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F30449%2Fhead;p=ceph.git mgr: pass MessageRef to monc.send_mon_message() less chance to leak memory see also: https://tracker.ceph.com/issues/37884 Signed-off-by: Kefu Chai --- diff --git a/src/mgr/DaemonServer.cc b/src/mgr/DaemonServer.cc index ba6c7f8c4a8..6722d0812ed 100644 --- a/src/mgr/DaemonServer.cc +++ b/src/mgr/DaemonServer.cc @@ -2356,7 +2356,7 @@ void DaemonServer::send_report() } } - auto m = new MMonMgrReport(); + auto m = ceph::make_message(); 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() diff --git a/src/mgr/MgrStandby.cc b/src/mgr/MgrStandby.cc index 3bcb68431c7..465af9299ec 100644 --- a/src/mgr/MgrStandby.cc +++ b/src/mgr/MgrStandby.cc @@ -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(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()