]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
msg: add Messenger::client_reset()
authorYan, Zheng <zyan@redhat.com>
Fri, 29 Mar 2019 08:58:21 +0000 (16:58 +0800)
committerYan, Zheng <zyan@redhat.com>
Mon, 30 Mar 2020 02:24:46 +0000 (10:24 +0800)
Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
src/msg/Messenger.h
src/msg/async/AsyncMessenger.cc
src/msg/async/AsyncMessenger.h

index 5ed44407c17d0f031b6f6caeabf1f4b3fd21f3b2..cd209130599b1cfe041f538d34f95819baa4306c 100644 (file)
@@ -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() {
index 6e989bca50729f139b25e4103ec2166652c5c970..8e98ef49313ef9e3dd4d4fddb3463027d17d394c 100644 (file)
@@ -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};
index 83a9c5a9b77c26e4275c4cb017ea041d2bb23595..625cb099c5a6f8f131082ee74734b5695ceb7558 100644 (file)
@@ -116,9 +116,11 @@ public:
 
   int bind(const entity_addr_t& bind_addr) override;
   int rebind(const std::set<int>& 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;