From: ownedu Date: Tue, 10 Oct 2017 02:16:05 +0000 (+0800) Subject: msg/async/rdma: fix a coredump bug which is introduced by PR #18053, X-Git-Tag: v13.0.1~588^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F18204%2Fhead;p=ceph.git msg/async/rdma: fix a coredump bug which is introduced by PR #18053, where the iterator is not working properly after erase(). Signed-off-by: Yan Lei --- diff --git a/src/msg/async/rdma/RDMAStack.cc b/src/msg/async/rdma/RDMAStack.cc index 080abb6d07e..f02f30529d1 100644 --- a/src/msg/async/rdma/RDMAStack.cc +++ b/src/msg/async/rdma/RDMAStack.cc @@ -244,17 +244,20 @@ void RDMADispatcher::polling() perf_logger->set(l_msgr_rdma_inflight_tx_chunks, inflight); if (num_dead_queue_pair) { Mutex::Locker l(lock); // FIXME reuse dead qp because creating one qp costs 1 ms - for (auto &i : dead_queue_pairs) { + auto it = dead_queue_pairs.begin(); + while (it != dead_queue_pairs.end()) { + auto i = *it; // Bypass QPs that do not collect all Tx completions yet. - if (i->get_tx_wr()) - continue; - ldout(cct, 10) << __func__ << " finally delete qp=" << i << dendl; - delete i; - auto it = std::find(dead_queue_pairs.begin(), dead_queue_pairs.end(), i); - if (it != dead_queue_pairs.end()) - dead_queue_pairs.erase(it); - perf_logger->dec(l_msgr_rdma_active_queue_pair); - --num_dead_queue_pair; + if (i->get_tx_wr()) { + ldout(cct, 20) << __func__ << " bypass qp=" << i << " tx_wr=" << i->get_tx_wr() << dendl; + ++it; + } else { + ldout(cct, 10) << __func__ << " finally delete qp=" << i << dendl; + delete i; + it = dead_queue_pairs.erase(it); + perf_logger->dec(l_msgr_rdma_active_queue_pair); + --num_dead_queue_pair; + } } } if (!num_qp_conn && done && dead_queue_pairs.empty())