From cdb500e5304100b96a50ff50a4c6a5178b95784f Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 20 Jun 2011 15:39:16 -0700 Subject: [PATCH] mon: do not copy subscription xlist xlist is not copyable. Signed-off-by: Sage Weil --- src/mon/MDSMonitor.cc | 4 +++- src/mon/Monitor.cc | 12 +++++++----- src/mon/OSDMonitor.cc | 4 +++- src/mon/Session.h | 7 +++++-- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/mon/MDSMonitor.cc b/src/mon/MDSMonitor.cc index d5c797eb83de3..39186404550be 100644 --- a/src/mon/MDSMonitor.cc +++ b/src/mon/MDSMonitor.cc @@ -845,7 +845,9 @@ bool MDSMonitor::prepare_command(MMonCommand *m) void MDSMonitor::check_subs() { string type = "mdsmap"; - xlist::iterator p = mon->session_map.subs[type].begin(); + if (mon->session_map.subs.count(type) == 0) + return; + xlist::iterator p = mon->session_map.subs[type]->begin(); while (!p.end()) { Subscription *sub = *p; ++p; diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index 2baefb41286de..e3ad5e0f17c53 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -141,13 +141,13 @@ Monitor::~Monitor() for (vector::iterator p = paxos.begin(); p != paxos.end(); p++) delete *p; //clean out MonSessionMap's subscriptions - for (map >::iterator i + for (map* >::iterator i = session_map.subs.begin(); i != session_map.subs.end(); ++i) { - while (!i->second.empty()) { - session_map.remove_sub(i->second.front()); - } + while (!i->second->empty()) + session_map.remove_sub(i->second->front()); + delete i->second; } //clean out MonSessionMap's sessions while (!session_map.sessions.empty()) { @@ -977,7 +977,9 @@ bool Monitor::ms_handle_reset(Connection *con) void Monitor::check_subs() { string type = "monmap"; - xlist::iterator p = session_map.subs[type].begin(); + if (session_map.subs.count(type) == 0) + return; + xlist::iterator p = session_map.subs[type]->begin(); while (!p.end()) { Subscription *sub = *p; ++p; diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 63e09f8153928..a87a833f38807 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -952,7 +952,9 @@ epoch_t OSDMonitor::blacklist(entity_addr_t a, utime_t until) void OSDMonitor::check_subs() { string type = "osdmap"; - xlist::iterator p = mon->session_map.subs[type].begin(); + if (mon->session_map.subs.count(type) == 0) + return; + xlist::iterator p = mon->session_map.subs[type]->begin(); while (!p.end()) { Subscription *sub = *p; ++p; diff --git a/src/mon/Session.h b/src/mon/Session.h index b4827d07b9575..c6957a67e4b56 100644 --- a/src/mon/Session.h +++ b/src/mon/Session.h @@ -73,7 +73,7 @@ struct MonSession : public RefCountedObject { struct MonSessionMap { xlist sessions; - map > subs; + map* > subs; multimap by_osd; void remove_session(MonSession *s) { @@ -126,7 +126,10 @@ struct MonSessionMap { } else { sub = new Subscription(s, what); s->sub_map[what] = sub; - subs[what].push_back(&sub->type_item); + + if (!subs.count(what)) + subs[what] = new xlist; + subs[what]->push_back(&sub->type_item); } sub->next = start; sub->onetime = onetime; -- 2.39.5