From 4b9c85a0152b1d14585f39bc957c5fe4dc1a7ae2 Mon Sep 17 00:00:00 2001 From: mike_m Date: Thu, 7 Jul 2011 10:11:13 +0000 Subject: [PATCH] ecore: Fix thread check for quicklaunch Signed-off-by: Mike McCormack git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/ecore@61109 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/lib/ecore/ecore_thread.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/src/lib/ecore/ecore_thread.c b/src/lib/ecore/ecore_thread.c index bd11567..2eba373 100644 --- a/src/lib/ecore/ecore_thread.c +++ b/src/lib/ecore/ecore_thread.c @@ -389,7 +389,6 @@ static LRWK(_ecore_thread_global_hash_lock); static LK(_ecore_thread_global_hash_mutex); static CD(_ecore_thread_global_hash_cond); -static PH(main_loop_thread); static Eina_Bool have_main_loop_thread = 0; static Eina_Trash *_ecore_thread_worker_trash = NULL; @@ -398,6 +397,22 @@ static int _ecore_thread_worker_count = 0; static void *_ecore_thread_worker(Ecore_Pthread_Data *pth); static Ecore_Pthread_Worker *_ecore_thread_worker_new(void); +static PH(get_main_loop_thread)(void) +{ + static PH(main_loop_thread); + static pid_t main_loop_pid; + pid_t pid = getpid(); + + if (pid != main_loop_pid) + { + main_loop_pid = pid; + main_loop_thread = PHS(); + have_main_loop_thread = 1; + } + + return main_loop_thread; +} + static void _ecore_thread_worker_free(Ecore_Pthread_Worker *worker) { @@ -764,11 +779,6 @@ _ecore_thread_worker_new(void) void _ecore_thread_init(void) { -#ifdef EFL_HAVE_THREADS - main_loop_thread = PHS(); - have_main_loop_thread = 1; -#endif - _ecore_thread_count_max = eina_cpu_count(); if (_ecore_thread_count_max <= 0) _ecore_thread_count_max = 1; @@ -850,9 +860,9 @@ _ecore_thread_assert_main_loop_thread(const char *function) { Eina_Bool good; #ifdef EFL_HAVE_THREADS - good = (main_loop_thread == PHS()); + good = PHE(get_main_loop_thread(), PHS()); #else - good = Eina_True; + good = EINA_TRUE; #endif if (!good) { @@ -992,7 +1002,7 @@ ecore_thread_cancel(Ecore_Thread *thread) LKL(_ecore_pending_job_threads_mutex); if ((have_main_loop_thread) && - (PHE(main_loop_thread, PHS()))) + (PHE(get_main_loop_thread(), PHS()))) { if (!work->feedback_run) EINA_LIST_FOREACH(_ecore_pending_job_threads, l, work) -- 2.7.4