From f5d6adbee3466da5968c728c4bd2745b48c94aec Mon Sep 17 00:00:00 2001 From: "Adam C. Emerson" Date: Thu, 28 Mar 2019 20:39:51 -0400 Subject: [PATCH] mon: Update Session.h to work without using namespace Signed-off-by: Adam C. Emerson --- src/mon/Session.h | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/src/mon/Session.h b/src/mon/Session.h index 46846c5e195..434395a7bf2 100644 --- a/src/mon/Session.h +++ b/src/mon/Session.h @@ -15,8 +15,13 @@ #ifndef CEPH_MON_SESSION_H #define CEPH_MON_SESSION_H -#include "global/global_context.h" +#include +#include + +#include "include/utime.h" #include "include/xlist.h" + +#include "global/global_context.h" #include "msg/msg_types.h" #include "mon/mon_types.h" @@ -29,13 +34,13 @@ struct MonSession; struct Subscription { MonSession *session; - string type; + std::string type; xlist::item type_item; version_t next; bool onetime; bool incremental_onetime; // has CEPH_FEATURE_INCSUBOSDMAP - Subscription(MonSession *s, const string& t) : session(s), type(t), type_item(this), + Subscription(MonSession *s, const std::string& t) : session(s), type(t), type_item(this), next(0), onetime(false), incremental_onetime(false) {} }; @@ -49,12 +54,12 @@ struct MonSession : public RefCountedObject { utime_t session_timeout; bool closed = false; xlist::item item; - set routed_request_tids; + std::set routed_request_tids; MonCap caps; bool authenticated = false; ///< true if auth handshake is complete - map sub_map; + std::map sub_map; epoch_t osd_epoch = 0; ///< the osdmap epoch sent to the mon client AuthServiceHandler *auth_handler = nullptr; @@ -63,8 +68,8 @@ struct MonSession : public RefCountedObject { ConnectionRef proxy_con; uint64_t proxy_tid = 0; - string remote_host; ///< remote host name - map> last_config; ///< most recently shared config + std::string remote_host; ///< remote host name + std::map> last_config; ///< most recently shared config bool any_config = false; MonSession(Connection *c) @@ -91,8 +96,8 @@ struct MonSession : public RefCountedObject { delete auth_handler; } - bool is_capable(string service, int mask) { - map args; + bool is_capable(std::string service, int mask) { + std::map args; return caps.is_capable( g_ceph_context, CEPH_ENTITY_TYPE_MON, @@ -110,8 +115,8 @@ struct MonSession : public RefCountedObject { struct MonSessionMap { xlist sessions; - map* > subs; - multimap by_osd; + std::map* > subs; + std::multimap by_osd; FeatureMap feature_map; // type -> features -> count MonSessionMap() {} @@ -129,14 +134,14 @@ struct MonSessionMap { void remove_session(MonSession *s) { ceph_assert(!s->closed); - for (map::iterator p = s->sub_map.begin(); p != s->sub_map.end(); ++p) { + for (std::map::iterator p = s->sub_map.begin(); p != s->sub_map.end(); ++p) { p->second->type_item.remove_myself(); delete p->second; } s->sub_map.clear(); s->item.remove_myself(); if (s->name.is_osd()) { - for (multimap::iterator p = by_osd.find(s->name.num()); + for (auto p = by_osd.find(s->name.num()); p->first == s->name.num(); ++p) if (p->second == s) { @@ -165,7 +170,7 @@ struct MonSessionMap { sessions.push_back(&s->item); s->get(); if (s->name.is_osd()) { - by_osd.insert(pair(s->name.num(), s)); + by_osd.insert(std::pair(s->name.num(), s)); } if (s->con_features) { feature_map.add(s->con_type, s->con_features); @@ -179,7 +184,7 @@ struct MonSessionMap { int n = by_osd.rbegin()->first + 1; int r = rand() % n; - multimap::iterator p = by_osd.lower_bound(r); + auto p = by_osd.lower_bound(r); if (p == by_osd.end()) --p; @@ -189,7 +194,8 @@ struct MonSessionMap { MonSession *s = NULL; - multimap::iterator b = p, f = p; + auto b = p; + auto f = p; bool backward = true, forward = true; while (backward || forward) { if (backward) { @@ -217,7 +223,7 @@ struct MonSessionMap { return s; } - void add_update_sub(MonSession *s, const string& what, version_t start, bool onetime, bool incremental_onetime) { + void add_update_sub(MonSession *s, const std::string& what, version_t start, bool onetime, bool incremental_onetime) { Subscription *sub = 0; if (s->sub_map.count(what)) { sub = s->sub_map[what]; @@ -241,7 +247,7 @@ struct MonSessionMap { } }; -inline ostream& operator<<(ostream& out, const MonSession& s) +inline std::ostream& operator<<(std::ostream& out, const MonSession& s) { out << "MonSession(" << s.name << " " << s.addrs << " is " << (s.closed ? "closed" : "open") -- 2.39.5