From: Haomai Wang Date: Tue, 23 Dec 2014 12:27:05 +0000 (+0800) Subject: AsyncMessenger: Fix leak memory X-Git-Tag: v0.92~84^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F3219%2Fhead;p=ceph.git AsyncMessenger: Fix leak memory Signed-off-by: Haomai Wang --- diff --git a/src/msg/async/AsyncConnection.cc b/src/msg/async/AsyncConnection.cc index 881db821db4..ef5d0459717 100644 --- a/src/msg/async/AsyncConnection.cc +++ b/src/msg/async/AsyncConnection.cc @@ -1499,8 +1499,8 @@ int AsyncConnection::handle_connect_msg(ceph_msg_connect &connect, bufferlist &a } ldout(async_msgr->cct, 0) << __func__ << "accept connect_seq " << connect.connect_seq - << " vs existing " << existing->connect_seq - << " state " << existing->state << dendl; + << " vs existing " << existing->connect_seq + << " state " << existing->state << dendl; if (connect.connect_seq == 0 && existing->connect_seq > 0) { ldout(async_msgr->cct,0) << __func__ << " accept peer reset, then tried to connect to us, replacing" << dendl; diff --git a/src/msg/async/AsyncMessenger.cc b/src/msg/async/AsyncMessenger.cc index 6886fe6e2a9..b6ba1446bc2 100644 --- a/src/msg/async/AsyncMessenger.cc +++ b/src/msg/async/AsyncMessenger.cc @@ -465,20 +465,7 @@ void AsyncMessenger::wait() ldout(cct,20) << __func__ << ": stopped processor thread" << dendl; // close all connections - lock.Lock(); - { - ldout(cct, 10) << __func__ << ": closing connections" << dendl; - - while (!conns.empty()) { - ceph::unordered_map::iterator it = conns.begin(); - AsyncConnectionRef p = it->second; - ldout(cct, 5) << __func__ << " " << it->first << " " << p << dendl; - conns.erase(it); - p->mark_down(); - ms_deliver_handle_reset(p.get()); - } - } - lock.Unlock(); + mark_down_all(); ldout(cct, 10) << __func__ << ": done." << dendl; ldout(cct, 1) << __func__ << " complete." << dendl; @@ -635,11 +622,19 @@ void AsyncMessenger::mark_down_all() while (!conns.empty()) { ceph::unordered_map::iterator it = conns.begin(); AsyncConnectionRef p = it->second; - ldout(cct, 5) << __func__ << " " << it->first << " " << p << dendl; + ldout(cct, 5) << __func__ << " mark down " << it->first << " " << p << dendl; conns.erase(it); p->mark_down(); ms_deliver_handle_reset(p.get()); } + + while (!deleted_conns.empty()) { + set::iterator it = deleted_conns.begin(); + AsyncConnectionRef p = *it; + ldout(cct, 5) << __func__ << " delete " << p << dendl; + p->put(); + deleted_conns.erase(it); + } lock.Unlock(); }