From fb746fda8ea78191663cee26ba4af62aa6af4a1f Mon Sep 17 00:00:00 2001 From: baoxy92 Date: Sat, 23 Dec 2023 04:58:29 +0000 Subject: [PATCH] =?UTF-8?q?oem=E8=AF=81=E4=B9=A6=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E8=B5=84=E6=BA=90=E6=B3=84=E9=9C=B2=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: baoxy92 --- .../server/src/drm_host_manager.cpp | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/services/drm_service/server/src/drm_host_manager.cpp b/services/drm_service/server/src/drm_host_manager.cpp index d5e19584..8edc7bd3 100644 --- a/services/drm_service/server/src/drm_host_manager.cpp +++ b/services/drm_service/server/src/drm_host_manager.cpp @@ -73,7 +73,6 @@ void DrmHostManager::StopServiceThread() if (StopThread) { StopThread(); } - dlclose(libHandle); ReleaseHandleAndKeySystemMap(libHandle); } loadedLibs.clear(); @@ -99,11 +98,9 @@ void DrmHostManager::ProcessMessage() } if (libHandle) { std::lock_guard lockLib(libMutex); - dlclose(libHandle); ReleaseHandleAndKeySystemMap(libHandle); loadedLibs.erase(std::remove(loadedLibs.begin(), loadedLibs.end(), libHandle), loadedLibs.end()); - libHandle = nullptr; } } } @@ -122,6 +119,10 @@ void DrmHostManager::ReleaseHandleAndKeySystemMap(void *handle) it->second = nullptr; } handleAndKeySystemMap.erase(handle); + if (handle != nullptr) { + dlclose(handle); + handle = nullptr; + } } void DrmHostManager::ServiceThreadMain() @@ -140,6 +141,8 @@ void DrmHostManager::ServiceThreadMain() DRM_DEBUG_LOG("DrmHostManager::ServiceThreadMain fullPath:%{public}s.", fullPath.c_str()); libsToLoad.push_back(fullPath); } + closedir(dir); + dir = nullptr; } for (const auto &libpath : libsToLoad) { std::lock_guard lockLib(libMutex); @@ -155,16 +158,24 @@ void DrmHostManager::ServiceThreadMain() if (QueryMediaKeySystemName && SetMediaKeySystem && ThreadExitNotify && StartThread && StopThread) { std::string uuid; int32_t ret = QueryMediaKeySystemName(uuid); - DRM_CHECK_AND_RETURN_LOG(ret == DRM_OK, "QueryMediaKeySystemName faild."); + if (ret != DRM_OK) { + ReleaseHandleAndKeySystemMap(handle); + DRM_ERR_LOG("DrmHostManager::QueryMediaKeySystemName error!"); + continue; + } ret = CreateMediaKeySystem(uuid, hdiMediaKeySystem); + if (ret != DRM_OK) { + ReleaseHandleAndKeySystemMap(handle); + DRM_ERR_LOG("DrmHostManager::CreateMediaKeySystem error!"); + continue; + } std::lock_guard lockHandle(handleAndKeySystemMapMutex); handleAndKeySystemMap.insert(std::make_pair(handle, hdiMediaKeySystem)); - DRM_CHECK_AND_RETURN_LOG(ret == DRM_OK && hdiMediaKeySystem != nullptr, "CreateMediaKeySystem faild."); ret = SetMediaKeySystem(hdiMediaKeySystem); if (ret != DRM_OK) { ReleaseHandleAndKeySystemMap(handle); DRM_ERR_LOG("DrmHostManager::SetMediaKeySystem error!"); - return; + continue; } if (IsProvisionRequired()) { std::lock_guard lockLibMap(libMapMutex); @@ -173,19 +184,18 @@ void DrmHostManager::ServiceThreadMain() if (ret != DRM_OK) { ReleaseHandleAndKeySystemMap(handle); DRM_ERR_LOG("DrmHostManager::ThreadExitNotify error!"); - return; + continue; } ret = StartThread(); if (ret != DRM_OK) { ReleaseHandleAndKeySystemMap(handle); DRM_ERR_LOG("DrmHostManager::StartThread error!"); - return; + continue; } } else { - dlclose(handle); loadedLibs.pop_back(); ReleaseHandleAndKeySystemMap(handle); - DRM_DEBUG_LOG("OEM certificate exist!"); + DRM_DEBUG_LOG("Faild to obtain the symbol table in the so!"); } } }