c/multi: Make sure that wait thread has started in creation

Co-authored-by: Ryan Pavlik <ryan.pavlik@collabora.com>
Co-authored-by: Jakob Bornecrantz <jakob@collabora.com>
This commit is contained in:
Jakob Bornecrantz 2022-05-25 15:57:57 +01:00
parent 3e9a5da3c6
commit 72dbed3ab5
2 changed files with 17 additions and 0 deletions

View file

@ -223,6 +223,10 @@ run_func(void *ptr)
os_thread_helper_lock(&mc->wait_thread.oth);
// Signal the start funtion that we are enterting the loop.
mc->wait_thread.alive = true;
os_thread_helper_signal_locked(&mc->wait_thread.oth);
while (os_thread_helper_is_running_locked(&mc->wait_thread.oth)) {
if (mc->wait_thread.xcsem == NULL && mc->wait_thread.xcf == NULL) {
@ -923,6 +927,16 @@ multi_compositor_create(struct multi_system_compositor *msc,
// Last start the wait thread.
os_thread_helper_start(&mc->wait_thread.oth, run_func, mc);
os_thread_helper_lock(&mc->wait_thread.oth);
// Wait for the wait thread to fully start.
while (!mc->wait_thread.alive) {
os_thread_helper_wait_locked(&mc->wait_thread.oth);
}
os_thread_helper_unlock(&mc->wait_thread.oth);
*out_xcn = &mc->base;
return XRT_SUCCESS;

View file

@ -143,6 +143,9 @@ struct multi_compositor
//! The wait thread itself
struct os_thread_helper oth;
//! Have we gotten to the loop?
bool alive;
//! Is the thread waiting, if so the client should block.
bool waiting;