From 3c1771762490c51cafb945470c4443cac0bfb389 Mon Sep 17 00:00:00 2001 From: yangsu13 Date: Thu, 23 Oct 2025 18:09:39 +0800 Subject: [PATCH] librocdxg: Remove std::call_once to fix repeated libdxcore.so loading failures The use of std::call_once caused the initialization flag to be set permanently, preventing proper re-attempts to load libdxcore.so when needed. This change removes the once_flag mechanism and relies solely on dxcore_handle_ checks to manage library loading, allowing proper re-initialization attempts. Signed-off-by: yangsu13 Reviewed-by: Flora Cui --- dxcore_loader.cpp | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/dxcore_loader.cpp b/dxcore_loader.cpp index ec6a4c8e87..5d38d69c8d 100644 --- a/dxcore_loader.cpp +++ b/dxcore_loader.cpp @@ -55,24 +55,21 @@ DxcoreLoader::~DxcoreLoader() { } bool DxcoreLoader::Initialize() { - std::call_once(init_flag_, [this]() { - // Attempt to load libdxcore.so - dlerror(); // Clear error - dxcore_handle_ = dlopen("libdxcore.so", RTLD_LAZY); + dlerror(); // Clear error + dxcore_handle_ = dlopen("libdxcore.so", RTLD_LAZY); - if (!dxcore_handle_) { - pr_err("[DxcoreLoader] Cannot load libdxcore.so: %s\n", dlerror()); - return; - } + if (!dxcore_handle_) { + pr_err("[DxcoreLoader] Cannot load libdxcore.so: %s\n", dlerror()); + return false; + } - pr_info("[DxcoreLoader] libdxcore.so loaded successfully\n"); - if (!LoadDxcoreApis()) { - // If API loading failed, close the handle to indicate failure - dlclose(dxcore_handle_); - dxcore_handle_ = nullptr; - return; - } - }); + pr_info("[DxcoreLoader] libdxcore.so loaded successfully\n"); + if (!LoadDxcoreApis()) { + // If API loading failed, close the handle to indicate failure + dlclose(dxcore_handle_); + dxcore_handle_ = nullptr; + return false; + } return IsLoaded(); }