From 090ba0e235a84a86cedf913f1f9bb87cb753da34 Mon Sep 17 00:00:00 2001 From: Christian Prochaska Date: Tue, 11 Sep 2018 18:57:40 +0200 Subject: [PATCH] arora: call main function from dedicated thread The Arora main thread sometimes blocks on a pthread condition variable, which prevents Genode signal processing with the current implementation. This is especially a problem when the thread who could unblock the main thread calls 'Libc::suspend()'. As a workaround until the pthread locking mechanisms get adapted to the Genode libc execution model, the Arora main function can be called from a dedicated thread. Fixes #2978 --- repos/ports/src/app/arora/arora_component.cc | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/repos/ports/src/app/arora/arora_component.cc b/repos/ports/src/app/arora/arora_component.cc index 3df9ed3344..adb8e5d124 100644 --- a/repos/ports/src/app/arora/arora_component.cc +++ b/repos/ports/src/app/arora/arora_component.cc @@ -16,6 +16,7 @@ /* libc includes */ #include /* 'exit' */ +#include /* Qt includes */ #include @@ -26,6 +27,19 @@ extern "C" int main(int argc, char const **argv); extern void initialize_qt_core(Genode::Env &); extern void initialize_qt_gui(Genode::Env &); +/* + * The main function is called from a dedicated thread, because it sometimes + * blocks on a pthread condition variable, which prevents Genode signal + * processing with the current implementation. + */ +void *arora_main(void *) +{ + int argc = 1; + char const *argv[] = { "arora", 0 }; + + exit(main(argc, argv)); +} + void Libc::Component::construct(Libc::Env &env) { Libc::with_libc([&] { @@ -34,9 +48,7 @@ void Libc::Component::construct(Libc::Env &env) initialize_qt_gui(env); QPluginWidget::env(env); - int argc = 1; - char const *argv[] = { "arora", 0 }; - - exit(main(argc, argv)); + pthread_t main_thread; + pthread_create(&main_thread, nullptr, arora_main, nullptr); }); }