Protect Session Map with a Recursive Mutex
(This is a merge of http://go/wvgerrit/72764) Netflix has identified a calling pattern that causes this mutex to be taken recursively. This is not guaranteed to be safe for Widevine's old custom Lock implementation nor std::mutex. However, it is guaranteed to be safe for std::recursive_mutex. This patch updates the mutex in use accordingly. In the long-term, this lock needs to be reconsidered, as already noted by comments in the code. It would be great if the reconsidered locking did not require a recursive-safe lock. The TODO for this has been spun off into its own bug and the comment has been updated to point to this. Bug: 120471929 Test: CE CDM Unit Tests Test: Android Unit Tests Change-Id: I34df64456de4b469b75caf25a33f0bc53a5da330
This commit is contained in:
@@ -403,7 +403,7 @@ class CdmEngine {
|
||||
// Protect release_key_sets_ from non-thread-safe operations.
|
||||
std::mutex release_key_sets_lock_;
|
||||
|
||||
// TODO(rfrias): Replace with two sets of locks, one to protect
|
||||
// TODO(b/124471172): Replace with two sets of locks, one to protect
|
||||
// the CdmSessionMap and a per-session lock to control access to
|
||||
// session usage/destruction.
|
||||
// Locks the session map |session_map_| and session usage/destruction
|
||||
@@ -412,7 +412,9 @@ class CdmEngine {
|
||||
// The layer above the CDM implementation is expected to handle thread
|
||||
// synchronization to make sure other functions that access sessions do not
|
||||
// occur simultaneously with OpenSession or CloseSession.
|
||||
std::mutex session_map_lock_;
|
||||
// This mutex must be recursive because it is sometimes held while callbacks
|
||||
// occur that may subsequently call back into CdmEngine.
|
||||
std::recursive_mutex session_map_lock_;
|
||||
|
||||
CORE_DISALLOW_COPY_AND_ASSIGN(CdmEngine);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user