bugfix: SessionTrack: strict ordering of queing a work Holds a mutex in changing a flag and notifying. wait_for() can takes 2 seconds when it receives cond_var notification before flag setting. Bug: 385027407 Test: l3 stress ranging (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:9cf4b74885ba78251796875422e57830645dc9a9) Merged-In: I197037b95584e74d443817055df2ed9124b025b2 Change-Id: I197037b95584e74d443817055df2ed9124b025b2
diff --git a/halimpl/hal/sessionTrack.cc b/halimpl/hal/sessionTrack.cc index c98d748..af3ebdb 100644 --- a/halimpl/hal/sessionTrack.cc +++ b/halimpl/hal/sessionTrack.cc
@@ -659,6 +659,7 @@ break; } if (msg->sync_) { + std::lock_guard<std::mutex> lock(sync_mutex_); msg->cond_flag = true; msg->cond_.notify_one(); } @@ -676,7 +677,7 @@ if (msg->sync_) { std::unique_lock<std::mutex> lock(sync_mutex_); if (!msg->cond_.wait_for(lock, std::chrono::milliseconds(kQueueTimeoutMs), - [msg] { return msg->cond_flag; })) { + [&msg] { return msg->cond_flag; })) { NXPLOG_UCIHAL_E("SessionTrack: timeout to process %d", static_cast<int>(msg->type_)); } }