Skip to content

Commit

Permalink
msg/async/rdma: fix a coredump bug which is introduced by PR ceph#18053,
Browse files Browse the repository at this point in the history
where the iterator is not working properly after erase().

Signed-off-by: Yan Lei <yongyou.yl@alibaba-inc.com>
  • Loading branch information
ownedu committed Oct 10, 2017
1 parent 980f18d commit f73bb15
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/msg/async/rdma/RDMAStack.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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, 10) << __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())
Expand Down

0 comments on commit f73bb15

Please sign in to comment.