From 6aefa60a0aed40e9e94abea8bff3a0c1ce7aa3d0 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Thu, 9 Aug 2012 12:17:47 +0000 Subject: [PATCH] ecore: add ecore_fork_reset() SVN revision: 75045 --- legacy/ecore/ChangeLog | 1 + legacy/ecore/NEWS | 1 + legacy/ecore/src/lib/ecore/Ecore.h | 3 ++- legacy/ecore/src/lib/ecore/ecore.c | 23 ++++++++++++++++------- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/legacy/ecore/ChangeLog b/legacy/ecore/ChangeLog index c9f654bebb..00b372f0f7 100644 --- a/legacy/ecore/ChangeLog +++ b/legacy/ecore/ChangeLog @@ -851,3 +851,4 @@ 2012-08-09 Cedric Bail * Correctly shutdown Ecore_Thread. + * Add a way to reset Ecore_Thread internal pipe after a fork via ecore_fork_reset. diff --git a/legacy/ecore/NEWS b/legacy/ecore/NEWS index 0500358030..ca58a1298f 100644 --- a/legacy/ecore/NEWS +++ b/legacy/ecore/NEWS @@ -6,6 +6,7 @@ Changes since Ecore 1.2.0: Additions: * ecore: - Add ecore_main_fd_handler_file_add() + - Add ecore_fork_reset() * ecore_evas: - Add transparency support on Windows (GDI engine only) - Add API functions to get/set an Ecore_Evas's profile. diff --git a/legacy/ecore/src/lib/ecore/Ecore.h b/legacy/ecore/src/lib/ecore/Ecore.h index 9140b473b6..3c8edb78d5 100644 --- a/legacy/ecore/src/lib/ecore/Ecore.h +++ b/legacy/ecore/src/lib/ecore/Ecore.h @@ -373,13 +373,14 @@ extern "C" { #endif /** - * @defgroup Ecore_Init_Group Ecore initialization and shutdown functions. + * @defgroup Ecore_Init_Group Ecore initialization, shutdown functions and reset on fork. * * @{ */ EAPI int ecore_init(void); EAPI int ecore_shutdown(void); +EAPI void ecore_fork_reset(void); /** * @} diff --git a/legacy/ecore/src/lib/ecore/ecore.c b/legacy/ecore/src/lib/ecore/ecore.c index b7e47dc2b2..d8dc359bfc 100644 --- a/legacy/ecore/src/lib/ecore/ecore.c +++ b/legacy/ecore/src/lib/ecore/ecore.c @@ -80,6 +80,7 @@ static void _thread_callback(void *data, static Eina_List *_thread_cb = NULL; static Ecore_Pipe *_thread_call = NULL; static Eina_Lock _thread_safety; +static const int wakeup = 42; static int _thread_loop = 0; static Eina_Lock _thread_mutex; @@ -175,11 +176,8 @@ ecore_init(void) eina_condition_new(&_thread_cond, &_thread_mutex); eina_lock_new(&_thread_feedback_mutex); eina_condition_new(&_thread_feedback_cond, &_thread_feedback_mutex); - if (!_thread_call) - { - _thread_call = ecore_pipe_add(_thread_callback, NULL); - eina_lock_new(&_thread_safety); - } + _thread_call = ecore_pipe_add(_thread_callback, NULL); + eina_lock_new(&_thread_safety); eina_lock_new(&_thread_id_lock); @@ -307,12 +305,23 @@ unlock: return _ecore_init_count; } +EAPI void +ecore_fork_reset(void) +{ + eina_lock_take(&_thread_safety); + + ecore_pipe_del(_thread_call); + _thread_call = ecore_pipe_add(_thread_callback, NULL); + /* If there was something in the pipe, trigger a wakeup again */ + if (_thread_cb) ecore_pipe_write(_thread_call, &wakeup, sizeof (int)); + + eina_lock_release(&_thread_safety); +} + /** * @} */ -static int wakeup = 42; - EAPI void ecore_main_loop_thread_safe_call_async(Ecore_Cb callback, void *data)