From: Yan, Zheng Date: Fri, 29 Mar 2019 08:58:21 +0000 (+0800) Subject: msg: add Messenger::client_reset() X-Git-Tag: v15.2.5~24^2~8 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2e57b8f94eb6d23e1c1808adb76fdcd895cf4cd8;p=ceph.git msg: add Messenger::client_reset() Signed-off-by: "Yan, Zheng" (cherry picked from commit a716bc7f9b9fc4665193bda61b2b17057888ef76) Conflicts: src/msg/async/AsyncMessenger.h - rebind function declaration looks different in octopus --- diff --git a/src/msg/Messenger.h b/src/msg/Messenger.h index c00374c114d..3620a7e5ae0 100644 --- a/src/msg/Messenger.h +++ b/src/msg/Messenger.h @@ -416,6 +416,8 @@ public: */ virtual int bind(const entity_addr_t& bind_addr) = 0; + virtual int bindv(const entity_addrvec_t& addrs); + /** * This function performs a full restart of the Messenger component, * whatever that means. Other entities who connect to this @@ -432,10 +434,15 @@ public: * is true. * @param bind_addr The address to bind to. * @return 0 on success, or -1 on error, or -errno if + * we can be more specific about the failure. */ virtual int client_bind(const entity_addr_t& bind_addr) = 0; - virtual int bindv(const entity_addrvec_t& addrs); + /** + * reset the 'client' Messenger. Mark all the existing Connections down + * and update 'nonce'. + */ + virtual int client_reset() = 0; virtual bool should_use_msgr2() { diff --git a/src/msg/async/AsyncMessenger.cc b/src/msg/async/AsyncMessenger.cc index 4f1224284f2..7595b35d77c 100644 --- a/src/msg/async/AsyncMessenger.cc +++ b/src/msg/async/AsyncMessenger.cc @@ -503,6 +503,24 @@ void AsyncMessenger::_finish_bind(const entity_addrvec_t& bind_addrs, did_bind = true; } +int AsyncMessenger::client_reset() +{ + mark_down_all(); + + std::scoped_lock l{lock}; + // adjust the nonce; we want our entity_addr_t to be truly unique. + nonce += 1000000; + ldout(cct, 10) << __func__ << " new nonce " << nonce << dendl; + + entity_addrvec_t newaddrs = *my_addrs; + for (auto& a : newaddrs.v) { + a.set_nonce(nonce); + } + set_myaddrs(newaddrs); + _init_local_connection(); + return 0; +} + int AsyncMessenger::start() { std::scoped_lock l{lock}; diff --git a/src/msg/async/AsyncMessenger.h b/src/msg/async/AsyncMessenger.h index 6e18281f1b9..3ce1b61ce60 100644 --- a/src/msg/async/AsyncMessenger.h +++ b/src/msg/async/AsyncMessenger.h @@ -116,9 +116,11 @@ public: int bind(const entity_addr_t& bind_addr) override; int rebind(const set& avoid_ports) override; + int bindv(const entity_addrvec_t& bind_addrs) override; + int client_bind(const entity_addr_t& bind_addr) override; - int bindv(const entity_addrvec_t& bind_addrs) override; + int client_reset() override; bool should_use_msgr2() override;