优化dlclose的使用

Signed-off-by: guoyi <guoyi39@huawei.com>
This commit is contained in:
guoyi 2024-08-03 22:23:46 +08:00
parent 14550342e2
commit 5691b7f178

View File

@ -431,7 +431,10 @@ bool DeviceProfileManager::LoadDpSyncAdapter()
HILOGI("File %{public}s canonicalization failed", soName.c_str());
return false;
}
void *so_handle = dlopen(soName.c_str(), RTLD_NOW);
void *so_handle = dlopen(soName.c_str(), RTLD_NOW | RTLD_NOLOAD);
if (so_handle == nullptr) {
so_handle = dlopen(soName.c_str(), RTLD_NOW);
}
if (so_handle == nullptr) {
HILOGI("load dp sync adapter so %{public}s failed", soName.c_str());
return false;
@ -453,7 +456,6 @@ bool DeviceProfileManager::LoadDpSyncAdapter()
if (dpSyncAdapter_->Initialize() != DP_SUCCESS) {
dpSyncAdapter_->Release();
dpSyncAdapter_ = nullptr;
dlclose(so_handle);
isAdapterSoLoaded_ = false;
HILOGI("dp sync adapter init failed");
return false;