Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0abf20ec authored by William Escande's avatar William Escande
Browse files

Lock mutex when accessing the idle_promise_

The value is sometimes caches and enforcing a lock here will prevent the
wrong promise to be used

Test: atest LeAclConnectionTest # repeat 10K
Bug: 262546952
Change-Id: I445bc38229e7e095f564adc94259e0b8924116e8
parent 909bc71f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -183,7 +183,7 @@ class LeAclConnectionTest : public ::testing::Test {

  void sync_handler() {
    ASSERT(thread_ != nullptr);
    ASSERT_TRUE(thread_->GetReactor()->WaitForIdle(2s));
    ASSERT(thread_->GetReactor()->WaitForIdle(2s));
  }

  AddressWithType address_1 =
+1 −0
Original line number Diff line number Diff line
@@ -142,6 +142,7 @@ void Reactor::Run() {
    if (waiting_for_idle && count == 0) {
      timeout_ms = -1;
      waiting_for_idle = false;
      std::scoped_lock<std::mutex> lock(mutex_);
      idle_promise_->set_value();
      idle_promise_ = nullptr;
    }