]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
msg/async/AsyncMessenger: clear need_addr *after* we set our new addr
authorSage Weil <sage@redhat.com>
Sat, 26 Jan 2019 23:01:14 +0000 (17:01 -0600)
committerSage Weil <sage@redhat.com>
Sat, 26 Jan 2019 23:01:14 +0000 (17:01 -0600)
We check need_addr at the top without a lock held, so we need to be sure
we finished our work before we clear it, or else when there are two racing
threads the first will get the clock and clear the value and the second
will do nothing and see the unlearned value before the first finishes.

Signed-off-by: Sage Weil <sage@redhat.com>
src/msg/async/AsyncMessenger.cc

index cbb3972792384fb4ff24bfc19271edeb9fa69a25..908052f11c41cdf88c8b85d7439074854736ce74 100644 (file)
@@ -882,7 +882,6 @@ bool AsyncMessenger::learned_addr(const entity_addr_t &peer_addr_for_me)
     return false;
   std::lock_guard l(lock);
   if (need_addr) {
-    need_addr = false;
     if (my_addrs->empty()) {
       auto a = peer_addr_for_me;
       a.set_nonce(nonce);
@@ -913,6 +912,7 @@ bool AsyncMessenger::learned_addr(const entity_addr_t &peer_addr_for_me)
     ldout(cct, 1) << __func__ << " learned my addr " << *my_addrs
                  << " (peer_addr_for_me " << peer_addr_for_me << ")" << dendl;
     _init_local_connection();
+    need_addr = false;
     return true;
   }
   return false;