From cb86f7d19bfba262758615b3140c91b400577bd9 Mon Sep 17 00:00:00 2001 From: Jeremy Wu <jrwu@google.com> Date: Fri, 30 Dec 2022 11:13:30 +0000 Subject: [PATCH] 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 --- system/common/message_loop_thread.cc | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/system/common/message_loop_thread.cc b/system/common/message_loop_thread.cc index 7afa08acfb0..d4b1fa400cf 100644 --- a/system/common/message_loop_thread.cc +++ b/system/common/message_loop_thread.cc @@ -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(); { -- GitLab