From ad12b0d61b8c4565ee8a5f352689b9121da2bcd2 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Sun, 23 Jun 2013 08:53:09 -0700 Subject: [PATCH] mon: fix leak of MOSDFailure messages We need to discard/cancel/free the failure report messages before we cancel a report out. Assert in the dtor to ensure we didn't forget. Signed-off-by: Sage Weil Reviewed-by: Joao Eduardo Luis --- src/mon/OSDMonitor.cc | 6 ++++++ src/mon/OSDMonitor.h | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index cf0e45d9a65..9db57b9d93d 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -978,7 +978,13 @@ bool OSDMonitor::prepare_failure(MOSDFailure *m) << m->get_orig_source_inst() << "\n"; if (failure_info.count(target_osd)) { failure_info_t& fi = failure_info[target_osd]; + list ls; + fi.take_report_messages(ls); fi.cancel_report(reporter); + while (!ls.empty()) { + mon->no_reply(ls.front()); + ls.pop_front(); + } if (fi.reporters.empty()) { dout(10) << " removing last failure_info for osd." << target_osd << dendl; failure_info.erase(target_osd); diff --git a/src/mon/OSDMonitor.h b/src/mon/OSDMonitor.h index ef5ba77462b..5af3d0cb057 100644 --- a/src/mon/OSDMonitor.h +++ b/src/mon/OSDMonitor.h @@ -45,6 +45,10 @@ struct failure_reporter_t { failure_reporter_t() : num_reports(0), msg(NULL) {} failure_reporter_t(utime_t s) : num_reports(1), failed_since(s), msg(NULL) {} + ~failure_reporter_t() { + // caller should have taken this message before removing the entry. + assert(!msg); + } }; /// information about all failure reports for one osd -- 2.47.3