This is an automated email from the ASF dual-hosted git repository. wwbmmm pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/brpc.git
The following commit(s) were added to refs/heads/master by this push: new 257134d6 optimize the fallback code style (#3008) 257134d6 is described below commit 257134d688af3eaa1c4615c27dca0db2217e06ba Author: none <zhangqion...@users.noreply.github.com> AuthorDate: Wed Jul 23 10:17:07 2025 +0800 optimize the fallback code style (#3008) --- src/brpc/rdma/rdma_helper.cpp | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/brpc/rdma/rdma_helper.cpp b/src/brpc/rdma/rdma_helper.cpp index 100fa704..f7cd9ecd 100644 --- a/src/brpc/rdma/rdma_helper.cpp +++ b/src/brpc/rdma/rdma_helper.cpp @@ -337,16 +337,22 @@ static void OnRdmaAsyncEvent(Socket* m) { } static int ReadRdmaDynamicLib() { - g_handle_ibverbs = dlopen("libibverbs.so", RTLD_LAZY); - if (!g_handle_ibverbs) { - LOG(WARNING) << "Failed to load libibverbs.so " << dlerror() << " try libibverbs.so.1"; - // Clear existing error - dlerror(); - g_handle_ibverbs = dlopen("libibverbs.so.1", RTLD_LAZY); - if (!g_handle_ibverbs) { - LOG(ERROR) << "Fail to load libibverbs.so.1 due to " << dlerror(); - return -1; + const static char* const kRdmaLibs[] = { + "libibverbs.so", + "libibverbs.so.1" + }; + for (const char* lib : kRdmaLibs) { + dlerror(); // Clear existing error + g_handle_ibverbs = dlopen(lib, RTLD_LAZY); + if (g_handle_ibverbs) { + LOG(INFO) << "Successfully loaded " << lib; + break; } + LOG(WARNING) << "Failed to load " << lib << ": " << dlerror(); + } + if (!g_handle_ibverbs) { + LOG(ERROR) << "Failed to load any of the RDMA libraries"; + return -1; } LoadSymbol(g_handle_ibverbs, IbvGetDeviceList, "ibv_get_device_list"); --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org For additional commands, e-mail: dev-h...@brpc.apache.org