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 <Yang.Su2@amd.com>
Reviewed-by: Flora Cui <flora.cui@amd.com>
This commit is contained in:
yangsu13
2025-10-23 18:09:39 +08:00
کامیت شده توسط Frank Min
والد a32d71124f
کامیت 3c17717624
+13 -16
مشاهده پرونده
@@ -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();
}