From ba28c7cc2a8d20f342951a3465393509db2f309f Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 16 Jul 2013 14:49:55 -0700 Subject: [PATCH] mon/OSDMonitor: clean up waiting_for_map messages on shutdown Do not leak these. Fixes: #5643 Signed-off-by: Sage Weil Reviewed-by: Greg Farnum Reviewed-by: Joao Eduardo Luis --- src/mon/OSDMonitor.cc | 15 +++++++++++++++ src/mon/OSDMonitor.h | 1 + src/mon/PaxosService.cc | 2 ++ src/mon/PaxosService.h | 5 +++++ 4 files changed, 23 insertions(+) diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index eaec014516bab..2b4de6d426d06 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -308,6 +308,21 @@ void OSDMonitor::on_active() } } +void OSDMonitor::on_shutdown() +{ + dout(10) << __func__ << dendl; + map >::iterator p = waiting_for_map.begin(); + while (p != waiting_for_map.end()) { + while (!p->second.empty()) { + Message *m = p->second.front(); + dout(20) << " discarding " << m << " " << *m << dendl; + m->put(); + p->second.pop_front(); + } + waiting_for_map.erase(p++); + } +} + void OSDMonitor::update_logger() { dout(10) << "update_logger" << dendl; diff --git a/src/mon/OSDMonitor.h b/src/mon/OSDMonitor.h index 3d901a8f13963..d65532283210c 100644 --- a/src/mon/OSDMonitor.h +++ b/src/mon/OSDMonitor.h @@ -154,6 +154,7 @@ private: void encode_pending(MonitorDBStore::Transaction *t); virtual void encode_full(MonitorDBStore::Transaction *t); void on_active(); + void on_shutdown(); /** * do not let paxosservice periodically stash full osdmaps, or we will break our diff --git a/src/mon/PaxosService.cc b/src/mon/PaxosService.cc index f5416a8fa87d7..d6e67a1c4b4c0 100644 --- a/src/mon/PaxosService.cc +++ b/src/mon/PaxosService.cc @@ -313,6 +313,8 @@ void PaxosService::shutdown() } finish_contexts(g_ceph_context, waiting_for_finished_proposal, -EAGAIN); + + on_shutdown(); } void PaxosService::maybe_trim() diff --git a/src/mon/PaxosService.h b/src/mon/PaxosService.h index 6c8d9c0bcc48c..a5761d19ad837 100644 --- a/src/mon/PaxosService.h +++ b/src/mon/PaxosService.h @@ -445,6 +445,11 @@ public: */ virtual void on_active() { } + /** + * This is called when we are shutting down + */ + virtual void on_shutdown() {} + /** * this is called when activating on the leader * -- 2.39.5