Protect against race conditions when removing keys

[ Merge of http://go/wvgerrit/142229 and http://go/ag/16147655 ]

This adds concurrency protection to a session when keys or a
license is removed from a session.

Bug: 195625322
Test: GtsMediaTestCases, unit/integration tests, YT EME conformance test
Change-Id: I38601a58dc593ce053cb5457b9d42d2c35f3f041
This commit is contained in:
Rahul Frias
2021-10-29 01:43:34 -07:00
parent d808ae18b6
commit a4756e2a7f

View File

@@ -455,6 +455,7 @@ CdmResponseType CdmEngine::RestoreKey(const CdmSessionId& session_id,
CdmResponseType CdmEngine::RemoveKeys(const CdmSessionId& session_id) {
LOGI("session_id = %s", IdToString(session_id));
std::shared_ptr<CdmSession> session;
std::unique_lock<std::recursive_mutex> lock(session_map_lock_);
if (!session_map_.FindSession(session_id, &session)) {
LOGE("Session not found: session_id = %s", IdToString(session_id));
return SESSION_NOT_FOUND_5;
@@ -466,6 +467,7 @@ CdmResponseType CdmEngine::RemoveKeys(const CdmSessionId& session_id) {
CdmResponseType CdmEngine::RemoveLicense(const CdmSessionId& session_id) {
LOGI("session_id = %s", IdToString(session_id));
std::shared_ptr<CdmSession> session;
std::unique_lock<std::recursive_mutex> lock(session_map_lock_);
if (!session_map_.FindSession(session_id, &session)) {
LOGE("Session not found: session_id = %s", IdToString(session_id));
return SESSION_NOT_FOUND_19;