From 12d301a1994e7893c17015d1c5ac3b6c2d026a06 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Wed, 18 Sep 2019 12:46:09 +0800 Subject: [PATCH] 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 --- src/mgr/DaemonServer.cc | 4 ++-- src/mgr/MgrStandby.cc | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/mgr/DaemonServer.cc b/src/mgr/DaemonServer.cc index ba6c7f8c4a86..6722d0812ed5 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 3bcb68431c72..465af9299ec8 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() -- 2.47.3