[core, ios, qt, android] Close race condition in RunLoop (issue #9620)

Because a message we queue from the foreground may cause the background to complete, exit, and tear down the AsyncTask, we have to block queue processing until we've finished our call to AsyncTask::send().
Broadening the scope of a mutex is scary, but I audited the code of our four implementations of AsyncTask and I don't see any way this could cause a deadlock.
This commit is contained in:
Chris Loer
2017-11-22 13:18:22 -08:00
committed by Tobrun
parent 2a13bfd2c4
commit 966b6a53ce
4 changed files with 16 additions and 8 deletions

View File

@@ -217,8 +217,10 @@ LOOP_HANDLE RunLoop::getLoopHandle() {
}
void RunLoop::push(std::shared_ptr<WorkTask> task) {
withMutex([&] { queue.push(std::move(task)); });
impl->wake();
withMutex([&] {
queue.push(std::move(task));
impl->wake();
});
}
void RunLoop::run() {