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>
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);
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;