]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
msg/async/rdma: fix a coredump bug which is introduced by PR #18053,
authorownedu <yanlei_cv@aliyun.com>
Tue, 10 Oct 2017 02:16:05 +0000 (10:16 +0800)
committerownedu <yanlei_cv@aliyun.com>
Wed, 11 Oct 2017 06:31:30 +0000 (14:31 +0800)
where the iterator is not working properly after erase().

Signed-off-by: Yan Lei <yongyou.yl@alibaba-inc.com>
src/msg/async/rdma/RDMAStack.cc

index 080abb6d07efad47c6363ec5b5352e1b88970f56..f02f30529d179870eb127d43a88c426de6dfb159 100644 (file)
@@ -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())