Added locking to session table in oemcrypto_adapter_dynamic.

This change the merge from the android tree of:
https://widevine-internal-review.googlesource.com/7353

bug: 10447846

Change-Id: I0a2496fc6f225e0f3b23731c24087ddc6068c9cc
This commit is contained in:
Fred Gylys-Colwell
2013-09-04 11:06:10 -07:00
parent d3a8d10868
commit d475d0282a

View File

@@ -21,6 +21,7 @@
#include "level3.h"
#include "log.h"
#include "lock.h"
#include "file_store.h"
#include "properties.h"
@@ -314,6 +315,7 @@ class Adapter {
}
LevelSession get(OEMCrypto_SESSION session) {
AutoLock auto_lock(lookup_lock_);
map_iterator pair = session_map_.find(session);
if (pair == session_map_.end()) {
return LevelSession();
@@ -322,6 +324,7 @@ class Adapter {
}
OEMCryptoResult OpenSession(OEMCrypto_SESSION* session, SecurityLevel level) {
AutoLock auto_lock(lookup_lock_);
LevelSession new_session;
OEMCryptoResult result;
if (level == kLevelDefault && level1_valid_) {
@@ -344,6 +347,7 @@ class Adapter {
}
OEMCryptoResult CloseSession(OEMCrypto_SESSION session) {
AutoLock auto_lock(lookup_lock_);
map_iterator pair = session_map_.find(session);
if (pair == session_map_.end()) {
return OEMCrypto_ERROR_INVALID_SESSION;
@@ -360,6 +364,7 @@ class Adapter {
struct FunctionPointers level1_;
struct FunctionPointers level3_;
std::map<OEMCrypto_SESSION, LevelSession> session_map_;
Lock lookup_lock_;
// This is just for debugging the map between session ids.
// If we add this to the level 3 session id, then the external session
// id will match the internal session id in the last two digits.