Update to handle spurious wake up in conditional variable
Bug: 265234582 Bug: 217181322 Test: make libwvdrmengine Change-Id: I6256f60ab871184298c1bfc44632c501a2db018c
This commit is contained in:
@@ -44,6 +44,12 @@ using video_widevine::ProvisioningResponse;
|
|||||||
using wvcdm::kLevel3;
|
using wvcdm::kLevel3;
|
||||||
using wvcdm::kLevelDefault;
|
using wvcdm::kLevelDefault;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
using namespace std::chrono;
|
||||||
|
|
||||||
|
#define GET_TIME() \
|
||||||
|
((duration_cast<milliseconds>(system_clock::now().time_since_epoch())) \
|
||||||
|
.count())
|
||||||
|
#define TIMEOUT_IN_MILLISECONDS 2 * 60 * 1000 // 2 minutes
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
@@ -528,7 +534,16 @@ class WatchDog {
|
|||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(mutex_);
|
std::unique_lock<std::mutex> lock(mutex_);
|
||||||
if (running_) {
|
if (running_) {
|
||||||
condition_.wait_for(lock, std::chrono::minutes(2));
|
bool waitStatus = false;
|
||||||
|
time_t time = GET_TIME();
|
||||||
|
do {
|
||||||
|
waitStatus = condition_.wait_for(
|
||||||
|
lock, std::chrono::milliseconds(TIMEOUT_IN_MILLISECONDS),
|
||||||
|
[time, this]() {
|
||||||
|
return ((GET_TIME() > time + TIMEOUT_IN_MILLISECONDS) |
|
||||||
|
(!running_));
|
||||||
|
});
|
||||||
|
} while (waitStatus != true);
|
||||||
}
|
}
|
||||||
if (running_) {
|
if (running_) {
|
||||||
gave_up_ = true;
|
gave_up_ = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user