]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
msg/async/dpdk:add the handling of DPDK initialization failure 44285/head
authorChunsong Feng <fengchunsong@huawei.com>
Sat, 11 Dec 2021 01:11:18 +0000 (01:11 +0000)
committerChunsong Feng <fengchunsong@huawei.com>
Sun, 26 Dec 2021 05:54:36 +0000 (05:54 +0000)
If rte_eal_init returns with failure,the waiting msgr-worker thread is
woken up for exception handling.

Signed-off-by: Chunsong Feng <fengchunsong@huawei.com>
Reviewed-by: luo rixin <luorixin@huawei.com>
Reviewed-by: Han Fengzhe <hanfengzhe@hisilicon.com>
src/msg/async/dpdk/dpdk_rte.cc

index 3ebb64360b04a8f6cb79cef3d99650a054820b80..fdd107823a6bb65748332b2d27e07cf8d790a034 100644 (file)
@@ -137,17 +137,21 @@ namespace dpdk {
       if (!rte_initialized) {
         /* initialise the EAL for all */
         int ret = rte_eal_init(cargs.size(), cargs.data());
-        if (ret < 0)
-          return;
+       if (ret < 0) {
+          std::unique_lock locker(lock);
+          done = true;
+          cond.notify_all();
+          return ret;
+       }
         rte_initialized = true;
       }
 
-      std::unique_lock<std::mutex> l(lock);
+      std::unique_lock locker(lock);
       initialized = true;
       done = true;
       cond.notify_all();
       while (!stopped) {
-        cond.wait(l, [this] { return !funcs.empty() || stopped; });
+        cond.wait(locker, [this] { return !funcs.empty() || stopped; });
         if (!funcs.empty()) {
           auto f = std::move(funcs.front());
           funcs.pop_front();
@@ -156,10 +160,9 @@ namespace dpdk {
         }
       }
     });
-    std::unique_lock<std::mutex> l(lock);
-    while (!done)
-      cond.wait(l);
-    return 0;
+    std::unique_lock locker(lock);
+    cond.wait(locker, [&] { return done; });
+    return initialized ? 0 : -EIO;
   }
 
   size_t eal::mem_size(int num_cpus)