summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2015-02-26 19:45:53 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2015-02-26 19:52:07 +0900
commit02cda8633e83ea3832b3898a93750fe9a0927a37 (patch)
tree470ec1dcad08dbd50a672ccf012aa77610e67df1
parent2d3025e553e6b660e4dddc8f6990f10e2ec7084b (diff)
eina + ecore - fix main loop thread id tracking on fork
if you fork and even if you do ecore_fork_reset() a thread calling ecore_main_loop_thread_safe_call_async(0 for example eill end up resetting the mainloop thread id to itself (a non mainlopo thread) via calling eina_main_loop_is() since pid changed. there is little point in doing this so remove the pid tracking from eina and ensure mainloop thread id is updated in ecore's fork reset. @fix
-rw-r--r--src/lib/ecore/ecore.c1
-rw-r--r--src/lib/eina/eina_main.c31
2 files changed, 2 insertions, 30 deletions
diff --git a/src/lib/ecore/ecore.c b/src/lib/ecore/ecore.c
index 0e48584..298e685 100644
--- a/src/lib/ecore/ecore.c
+++ b/src/lib/ecore/ecore.c
@@ -486,6 +486,7 @@ ecore_fork_reset(void)
486 Eina_List *l, *ln; 486 Eina_List *l, *ln;
487 Ecore_Fork_Cb *fcb; 487 Ecore_Fork_Cb *fcb;
488 488
489 eina_main_loop_define();
489 eina_lock_take(&_thread_safety); 490 eina_lock_take(&_thread_safety);
490 491
491 ecore_pipe_del(_thread_call); 492 ecore_pipe_del(_thread_call);
diff --git a/src/lib/eina/eina_main.c b/src/lib/eina/eina_main.c
index d4edb24..236e0b7 100644
--- a/src/lib/eina/eina_main.c
+++ b/src/lib/eina/eina_main.c
@@ -108,7 +108,6 @@ EAPI DWORD _eina_main_loop;
108# else 108# else
109EAPI pthread_t _eina_main_loop; 109EAPI pthread_t _eina_main_loop;
110# endif 110# endif
111static pid_t _eina_pid;
112#endif 111#endif
113 112
114#ifdef MT 113#ifdef MT
@@ -285,7 +284,6 @@ eina_init(void)
285# else 284# else
286 _eina_main_loop = pthread_self(); 285 _eina_main_loop = pthread_self();
287# endif 286# endif
288 _eina_pid = getpid();
289#endif 287#endif
290 288
291#ifdef EINA_HAVE_DEBUG_THREADS 289#ifdef EINA_HAVE_DEBUG_THREADS
@@ -425,35 +423,9 @@ EAPI Eina_Bool
425eina_main_loop_is(void) 423eina_main_loop_is(void)
426{ 424{
427#ifdef EFL_HAVE_THREADS 425#ifdef EFL_HAVE_THREADS
428 pid_t pid; 426 if (pthread_equal(_eina_main_loop, pthread_self()))
429
430# ifdef _WIN32
431 if (_eina_main_loop == GetCurrentThreadId())
432 return EINA_TRUE;
433# else
434 if (pthread_equal(_eina_main_loop, pthread_self()))
435 return EINA_TRUE; 427 return EINA_TRUE;
436# endif
437
438 pid = getpid();
439# ifdef _WIN32
440 if (pid != _eina_pid)
441 {
442 _eina_pid = pid;
443 _eina_main_loop = GetCurrentThreadId();
444 return EINA_TRUE;
445 }
446#else
447 if (pid != _eina_pid)
448 {
449 /* This is in case of a fork, but don't like the solution */
450 _eina_pid = pid;
451 _eina_main_loop = pthread_self();
452 return EINA_TRUE;
453 }
454#endif
455#endif 428#endif
456
457 return EINA_FALSE; 429 return EINA_FALSE;
458} 430}
459 431
@@ -462,7 +434,6 @@ EAPI void
462eina_main_loop_define(void) 434eina_main_loop_define(void)
463{ 435{
464#ifdef EFL_HAVE_THREADS 436#ifdef EFL_HAVE_THREADS
465 _eina_pid = getpid();
466# ifdef _WIN32 437# ifdef _WIN32
467 _eina_main_loop = GetCurrentThreadId(); 438 _eina_main_loop = GetCurrentThreadId();
468# else 439# else