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

Commit cb86f7d1 authored by Jeremy Wu's avatar Jeremy Wu
Browse files

Floss: use QuitWhenIdle for thread-safety

In |MessageLoopThread::ShutDown|, we invoke |QuitWhenIdleClosure| that
is not thread-safe, but |ShutDown| is meant to be called from a
different thread than the owner of the |MessageLoopThread|.

In this CL, we change it to the thread-safe variant, |QuitWhenIdle|.

Bug: 263808792
Tag: #floss
Test: Build and verify it doesn't crash when dis/enabling BT
Change-Id: Id2b8f7537b82b25a5950b35ecd615a554b89670e
parent 712a1470
Loading
Loading
Loading
Loading
+1 −6
Original line number Diff line number Diff line
@@ -141,12 +141,7 @@ void MessageLoopThread::ShutDown() {
    CHECK_NE(thread_id_, base::PlatformThread::CurrentId())
        << __func__ << " should not be called on the thread itself. "
        << "Otherwise, deadlock may happen.";
    if (!message_loop_->task_runner()->PostTask(
            FROM_HERE, run_loop_->QuitWhenIdleClosure())) {
      LOG(FATAL) << __func__
                 << ": failed to post task to message loop for thread "
                 << *this;
    }
    run_loop_->QuitWhenIdle();
  }
  thread_->join();
  {