]> 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)
committerNathan Cutler <ncutler@suse.com>
Tue, 7 Jul 2020 15:22:46 +0000 (17:22 +0200)
Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
(cherry picked from commit a716bc7f9b9fc4665193bda61b2b17057888ef76)

Conflicts:
src/msg/async/AsyncMessenger.h
- rebind function declaration looks different in octopus

src/msg/Messenger.h
src/msg/async/AsyncMessenger.cc
src/msg/async/AsyncMessenger.h

index c00374c114d2d5ef02e270bd75fea9ca69d6ebf6..3620a7e5ae0b009a6061b7c9e1bf7d9fdfe5e52d 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 4f1224284f28ff98f770dca83207255428c74397..7595b35d77c2104802c40045afac129846510383 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 6e18281f1b9c43211607cbae7f794b6ac11b4a4a..3ce1b61ce604784663ac3ae743bd2e67313ed940 100644 (file)
@@ -116,9 +116,11 @@ public:
 
   int bind(const entity_addr_t& bind_addr) override;
   int rebind(const 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;