diff --git a/src/xrt/compositor/multi/comp_multi_compositor.c b/src/xrt/compositor/multi/comp_multi_compositor.c index e968cb845..a4a2734e8 100644 --- a/src/xrt/compositor/multi/comp_multi_compositor.c +++ b/src/xrt/compositor/multi/comp_multi_compositor.c @@ -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; diff --git a/src/xrt/compositor/multi/comp_multi_private.h b/src/xrt/compositor/multi/comp_multi_private.h index a974f3c32..b34002cf5 100644 --- a/src/xrt/compositor/multi/comp_multi_private.h +++ b/src/xrt/compositor/multi/comp_multi_private.h @@ -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;