diff options
author | Cedric BAIL <cedric@osg.samsung.com> | 2017-11-07 15:47:28 -0800 |
---|---|---|
committer | Cedric BAIL <cedric@osg.samsung.com> | 2017-11-07 16:08:39 -0800 |
commit | fa3e1dc784275cbcd2f0002cf30525528d5a2bc3 (patch) | |
tree | 397951b780801eef82615fc4b7084ed124d95d85 | |
parent | d125892601c6278bf40624843d637bbc0e1a0cf0 (diff) |
evas: rely on ecore to reset evas rendering thread on fork.
-rw-r--r-- | src/lib/evas/common/evas_thread_render.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/lib/evas/common/evas_thread_render.c b/src/lib/evas/common/evas_thread_render.c index 84ea7b4234..c823125f69 100644 --- a/src/lib/evas/common/evas_thread_render.c +++ b/src/lib/evas/common/evas_thread_render.c @@ -1,5 +1,6 @@ #include "evas_common_private.h" +#include "Ecore.h" #include <assert.h> static Eina_Thread evas_thread_worker; @@ -180,6 +181,43 @@ out: return NULL; } +static void +evas_thread_fork_reset(void *data EINA_UNUSED) +{ + if (!eina_lock_new(&evas_thread_queue_lock)) + { + CRI("Could not create draw thread lock (%m)"); + goto on_error; + } + if (!eina_condition_new(&evas_thread_queue_condition, &evas_thread_queue_lock)) + { + CRI("Could not create draw thread condition (%m)"); + goto on_error; + } + + if (!eina_thread_create(&evas_thread_worker, EINA_THREAD_NORMAL, -1, + evas_thread_worker_func, NULL)) + { + CRI("Could not recreate draw thread."); + goto on_error; + } + + return ; + + on_error: + eina_lock_free(&evas_thread_queue_lock); + eina_condition_free(&evas_thread_queue_condition); + + evas_thread_worker = 0; + + free(evas_thread_queue_cache); + evas_thread_queue_cache = NULL; + evas_thread_queue_cache_max = 0; + eina_inarray_flush(&evas_thread_queue); + + eina_threads_shutdown(); +} + int evas_thread_init(void) { @@ -189,6 +227,8 @@ evas_thread_init(void) exit_thread = EINA_FALSE; evas_thread_exited = 0; + ecore_init(); + if(!eina_threads_init()) { CRI("Could not init eina threads"); @@ -215,6 +255,8 @@ evas_thread_init(void) goto fail_on_thread_creation; } + ecore_fork_reset_callback_add(evas_thread_fork_reset, NULL); + return init_count; fail_on_thread_creation: @@ -227,6 +269,7 @@ fail_on_lock_creation: fail_on_eina_thread_init: exit_thread = EINA_TRUE; evas_thread_exited = 1; + ecore_shutdown(); return --init_count; } @@ -244,8 +287,13 @@ evas_thread_shutdown(void) if (--init_count) return init_count; + if (!evas_thread_worker) + return init_count; + eina_lock_take(&evas_thread_queue_lock); + ecore_fork_reset_callback_del(evas_thread_fork_reset, NULL); + exit_thread = EINA_TRUE; eina_condition_signal(&evas_thread_queue_condition); @@ -275,5 +323,7 @@ timeout_shutdown: eina_threads_shutdown(); + ecore_shutdown(); + return 0; } |