Added mutex for reserved_license_ids_.

[ Merge of http://go/wvgerrit/150630 ]

DeviceFiles uses a static variable for tracking license IDs which
have been reserved by a CDM session before officially storing the
license on the device.  This variable was not protected by a mutex,
and a rare race condition would arise, either crashing the service
or getting it stuck in a loop.

This CL adds a mutex for protecting the set of reserved IDs.

Bug: 226555704
Test: device_files_unittest
Change-Id: Icdea88673c76c267b4b7db79697ec52ae8e2581e
This commit is contained in:
Alex Dale
2022-04-22 13:53:11 -07:00
parent 47ebc28f6a
commit a80a9fef26
2 changed files with 9 additions and 0 deletions

View File

@@ -5,6 +5,7 @@
#ifndef WVCDM_CORE_DEVICE_FILES_H_
#define WVCDM_CORE_DEVICE_FILES_H_
#include <mutex>
#include <set>
#include <string>
#include <vector>
@@ -369,6 +370,7 @@ class DeviceFiles {
#endif
static std::set<std::string> reserved_license_ids_;
static std::mutex reserved_license_ids_mutex_;
wvutil::FileSystem* file_system_;
CdmSecurityLevel security_level_;