From: Yan, Zheng Date: Fri, 29 Mar 2019 08:58:21 +0000 (+0800) Subject: msg: add Messenger::client_reset() X-Git-Tag: v16.1.0~2690^2~9 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a716bc7f9b9fc4665193bda61b2b17057888ef76;p=ceph.git msg: add Messenger::client_reset() Signed-off-by: "Yan, Zheng" --- diff --git a/src/msg/Messenger.h b/src/msg/Messenger.h index 5ed44407c17d..cd209130599b 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 6e989bca5072..8e98ef49313e 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 83a9c5a9b77c..625cb099c5a6 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 std::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;