eina + ecore - fix main loop thread id tracking on fork
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>
Thu, 26 Feb 2015 10:45:53 +0000 (19:45 +0900)
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>
Thu, 26 Feb 2015 10:47:51 +0000 (19:47 +0900)
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

src/lib/ecore/ecore.c
src/lib/eina/eina_main.c

index 0e48584..298e685 100644 (file)
@@ -486,6 +486,7 @@ ecore_fork_reset(void)
    Eina_List *l, *ln;
    Ecore_Fork_Cb *fcb;
    
+   eina_main_loop_define();
    eina_lock_take(&_thread_safety);
 
    ecore_pipe_del(_thread_call);
index aa39d27..ea85b30 100644 (file)
@@ -103,7 +103,6 @@ EAPI unsigned int eina_seed = 0;
 
 #ifdef EFL_HAVE_THREADS
 EAPI pthread_t _eina_main_loop;
-static pid_t _eina_pid;
 #endif
 
 #ifdef MT
@@ -272,7 +271,6 @@ eina_init(void)
 
 #ifdef EFL_HAVE_THREADS
    _eina_main_loop = pthread_self();
-   _eina_pid = getpid();
 #endif
 
 #ifdef EINA_HAVE_DEBUG_THREADS
@@ -412,20 +410,9 @@ EAPI Eina_Bool
 eina_main_loop_is(void)
 {
 #ifdef EFL_HAVE_THREADS
-  pid_t pid;
   if (pthread_equal(_eina_main_loop, pthread_self()))
      return EINA_TRUE;
-
-   pid = getpid();
-   if (pid != _eina_pid)
-     {
-        /* This is in case of a fork, but don't like the solution */
-        _eina_pid = pid;
-        _eina_main_loop = pthread_self();
-        return EINA_TRUE;
-     }
 #endif
-
    return EINA_FALSE;
 }
 
@@ -434,7 +421,6 @@ EAPI void
 eina_main_loop_define(void)
 {
 #ifdef EFL_HAVE_THREADS
-   _eina_pid = getpid();
    _eina_main_loop = pthread_self();
 #endif
 }