From: Chunsong Feng Date: Sat, 11 Dec 2021 01:11:18 +0000 (+0000) Subject: msg/async/dpdk:add the handling of DPDK initialization failure X-Git-Tag: v17.1.0~172^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=a5df6794e10a6e2d52e8afc131d9ccd3b9e933fc;p=ceph.git msg/async/dpdk:add the handling of DPDK initialization failure If rte_eal_init returns with failure,the waiting msgr-worker thread is woken up for exception handling. Signed-off-by: Chunsong Feng Reviewed-by: luo rixin Reviewed-by: Han Fengzhe --- diff --git a/src/msg/async/dpdk/dpdk_rte.cc b/src/msg/async/dpdk/dpdk_rte.cc index 3ebb64360b04a..fdd107823a6bb 100644 --- a/src/msg/async/dpdk/dpdk_rte.cc +++ b/src/msg/async/dpdk/dpdk_rte.cc @@ -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 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 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)