diff --git a/src/mon/MDSMonitor.cc b/src/mon/MDSMonitor.cc index 9a6af923d1e..08f297b649a 100644 --- a/src/mon/MDSMonitor.cc +++ b/src/mon/MDSMonitor.cc @@ -1503,29 +1503,33 @@ int MDSMonitor::filesystem_command( void MDSMonitor::check_subs() { - std::list types; - // Subscriptions may be to "mdsmap" (MDS and legacy clients), // "mdsmap.", or to "fsmap" for the full state of all // filesystems. Build a list of all the types we service // subscriptions for. - types.push_back("fsmap"); - types.push_back("fsmap.user"); - types.push_back("mdsmap"); + + std::vector types = { + "fsmap", + "fsmap.user", + "mdsmap", + }; + for (const auto &p : get_fsmap().filesystems) { const auto &fscid = p.first; - std::ostringstream oss; - oss << "mdsmap." << fscid; - types.push_back(oss.str()); + CachedStackStringStream cos; + *cos << "mdsmap." << fscid; + types.push_back(std::string(cos->strv())); } for (const auto &type : types) { - if (mon->session_map.subs.count(type) == 0) + auto& subs = mon->session_map.subs; + auto subs_it = subs.find(type); + if (subs_it == subs.end()) continue; - xlist::iterator p = mon->session_map.subs[type]->begin(); - while (!p.end()) { - Subscription *sub = *p; - ++p; + auto sub_it = subs_it->second->begin(); + while (!sub_it.end()) { + auto sub = *sub_it; + ++sub_it; // N.B. check_sub may remove sub! check_sub(sub); } }