Revert of "Prevent race conditions between decrypt and close session"

Merge from Widevine repo of http://go/wvgerrit/50481
Original CL http://go/wvgerrit/47520

The original CL was not completely merged to master on Android, so
this CL only reverts the left-over bits.

The original fix was not sufficient to address all race conditions.  A
subsequent CL will address them.

Bug: 73781703
Bug: 79158083
Bug: 79262108
Test: tested as part of http://go/ag/4674759

Change-Id: Ib6c55ab5434e08fe61e0f65623ac8c7b2dc5aaa1
This commit is contained in:
Fred Gylys-Colwell
2018-07-01 12:19:52 -07:00
parent 147f40a5ef
commit 22d9160219
3 changed files with 9 additions and 6 deletions

View File

@@ -12,10 +12,7 @@
namespace wvcdm {
CdmSessionMap::~CdmSessionMap() {
Terminate();
}
void CdmSessionMap::Terminate() {
AutoLock lock(lock_);
for (CdmIdToSessionMap::iterator i = sessions_.begin();
i != sessions_.end(); ++i) {
i->second->Close();
@@ -25,10 +22,12 @@ void CdmSessionMap::Terminate() {
}
void CdmSessionMap::Add(const std::string& id, CdmSession* session) {
AutoLock lock(lock_);
sessions_[id].reset(session);
}
bool CdmSessionMap::CloseSession(const std::string& id) {
AutoLock lock(lock_);
shared_ptr<CdmSession> session;
if (!FindSessionNoLock(id, &session)) {
return false;
@@ -39,11 +38,13 @@ bool CdmSessionMap::CloseSession(const std::string& id) {
}
bool CdmSessionMap::Exists(const std::string& id) {
AutoLock lock(lock_);
return sessions_.find(id) != sessions_.end();
}
bool CdmSessionMap::FindSession(const CdmSessionId& id,
shared_ptr<CdmSession>* session) {
AutoLock lock(lock_);
return FindSessionNoLock(id, session);
}
@@ -60,6 +61,7 @@ bool CdmSessionMap::FindSessionNoLock(const CdmSessionId& session_id,
void CdmSessionMap::GetSessionList(CdmSessionList& sessions) {
sessions.clear();
AutoLock lock(lock_);
for (CdmIdToSessionMap::iterator iter = sessions_.begin();
iter != sessions_.end(); ++iter) {
if (!(iter->second)->IsClosed()) {