Fix spurious wake up in dynamic adapter

The predicate version of wait_for() to avoid spurious wake up by
checking running_ status.

This is a fix to ag/21439870

Test: build widevine
Bug: 272424659
Bug: 271811708
Change-Id: I446fef8f4c8c58bcd47b885dba50643b3e5e1185
This commit is contained in:
Cong Lin
2023-03-09 21:41:50 +00:00
parent efd05207c8
commit 5ccb147bb8

View File

@@ -532,7 +532,10 @@ class WatchDog {
{
std::unique_lock<std::mutex> lock(mutex_);
if (running_) {
condition_.wait_for(lock, std::chrono::minutes(2));
if (!condition_.wait_for(lock, std::chrono::minutes(2),
[this]() { return !running_; })) {
LOGE("Level3 initialization timed out");
}
}
if (running_) {
gave_up_ = true;
@@ -857,7 +860,8 @@ class Adapter {
for (auto& name : library_names) {
level1_library_ = dlopen((name.c_str()), RTLD_NOW);
if (!level1_library_) {
LOGW("Could not load oemcrypto from path %s. %s", name.c_str(), dlerror());
LOGW("Could not load oemcrypto from path %s. %s", name.c_str(),
dlerror());
}
}
if (!level1_library_) {