From 18193e9918206ec4783e7f6551149c0504c6bb4a Mon Sep 17 00:00:00 2001 From: Mike McCormack Date: Thu, 7 Jul 2011 10:11:13 +0000 Subject: [PATCH] ecore: Fix thread check for quicklaunch Signed-off-by: Mike McCormack SVN revision: 61109 --- legacy/ecore/src/lib/ecore/ecore_thread.c | 28 +++++++++++++++-------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/legacy/ecore/src/lib/ecore/ecore_thread.c b/legacy/ecore/src/lib/ecore/ecore_thread.c index bd11567455..2eba3739c7 100644 --- a/legacy/ecore/src/lib/ecore/ecore_thread.c +++ b/legacy/ecore/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)