mirror of
https://github.com/ceph/ceph
synced 2025-01-31 07:22:56 +00:00
msg/async/ProtocolV2: only update socket_addr if we learned our addr
Signed-off-by: Sage Weil <sage@redhat.com>
This commit is contained in:
parent
5709fb9122
commit
16a0bbb0aa
@ -808,7 +808,7 @@ int AsyncMessenger::get_proto_version(int peer_type, bool connect) const
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AsyncMessenger::learned_addr(const entity_addr_t &peer_addr_for_me)
|
bool AsyncMessenger::learned_addr(const entity_addr_t &peer_addr_for_me)
|
||||||
{
|
{
|
||||||
// be careful here: multiple threads may block here, and readers of
|
// be careful here: multiple threads may block here, and readers of
|
||||||
// my_addr do NOT hold any lock.
|
// my_addr do NOT hold any lock.
|
||||||
@ -817,8 +817,8 @@ void AsyncMessenger::learned_addr(const entity_addr_t &peer_addr_for_me)
|
|||||||
// mutex. if it is already false, we need not retake the mutex at
|
// mutex. if it is already false, we need not retake the mutex at
|
||||||
// all.
|
// all.
|
||||||
if (!need_addr)
|
if (!need_addr)
|
||||||
return ;
|
return false;
|
||||||
lock.Lock();
|
std::lock_guard l(lock);
|
||||||
if (need_addr) {
|
if (need_addr) {
|
||||||
need_addr = false;
|
need_addr = false;
|
||||||
if (my_addrs->empty()) {
|
if (my_addrs->empty()) {
|
||||||
@ -844,8 +844,9 @@ void AsyncMessenger::learned_addr(const entity_addr_t &peer_addr_for_me)
|
|||||||
ldout(cct, 1) << __func__ << " learned my addr " << *my_addrs
|
ldout(cct, 1) << __func__ << " learned my addr " << *my_addrs
|
||||||
<< " (peer_addr_for_me " << peer_addr_for_me << ")" << dendl;
|
<< " (peer_addr_for_me " << peer_addr_for_me << ")" << dendl;
|
||||||
_init_local_connection();
|
_init_local_connection();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
lock.Unlock();
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int AsyncMessenger::reap_dead()
|
int AsyncMessenger::reap_dead()
|
||||||
|
@ -372,7 +372,7 @@ public:
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void learned_addr(const entity_addr_t &peer_addr_for_me);
|
bool learned_addr(const entity_addr_t &peer_addr_for_me);
|
||||||
void add_accept(Worker *w, ConnectedSocket cli_socket,
|
void add_accept(Worker *w, ConnectedSocket cli_socket,
|
||||||
const entity_addr_t &listen_addr,
|
const entity_addr_t &listen_addr,
|
||||||
const entity_addr_t &peer_addr);
|
const entity_addr_t &peer_addr);
|
||||||
|
@ -1383,12 +1383,11 @@ CtPtr ProtocolV2::handle_server_addrvec_and_identify(char *buffer, int r) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
connection->set_peer_addrs(paddrs);
|
connection->set_peer_addrs(paddrs);
|
||||||
connection->socket_addr = peer_addr_for_me;
|
|
||||||
|
|
||||||
ldout(cct, 20) << __func__ << " connect peer addr for me is "
|
ldout(cct, 20) << __func__ << " connect peer addr for me is "
|
||||||
<< peer_addr_for_me << dendl;
|
<< peer_addr_for_me << dendl;
|
||||||
connection->lock.unlock();
|
connection->lock.unlock();
|
||||||
messenger->learned_addr(peer_addr_for_me);
|
bool learned = messenger->learned_addr(peer_addr_for_me);
|
||||||
if (cct->_conf->ms_inject_internal_delays &&
|
if (cct->_conf->ms_inject_internal_delays &&
|
||||||
cct->_conf->ms_inject_socket_failures) {
|
cct->_conf->ms_inject_socket_failures) {
|
||||||
if (rand() % cct->_conf->ms_inject_socket_failures == 0) {
|
if (rand() % cct->_conf->ms_inject_socket_failures == 0) {
|
||||||
@ -1401,6 +1400,9 @@ CtPtr ProtocolV2::handle_server_addrvec_and_identify(char *buffer, int r) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
connection->lock.lock();
|
connection->lock.lock();
|
||||||
|
if (learned) {
|
||||||
|
connection->socket_addr = peer_addr_for_me;
|
||||||
|
}
|
||||||
if (state != CONNECTING_WAIT_BANNER_AND_IDENTIFY) {
|
if (state != CONNECTING_WAIT_BANNER_AND_IDENTIFY) {
|
||||||
ldout(cct, 1) << __func__
|
ldout(cct, 1) << __func__
|
||||||
<< " state changed while learned_addr, mark_down or "
|
<< " state changed while learned_addr, mark_down or "
|
||||||
|
Loading…
Reference in New Issue
Block a user