forked from enlightenment/efl
eina: actually check the pid only if we fail with main loop check.
NOTE: If we are out of luck this test can work after a fork, but most of the time it will be correct and cost nothing, instead of costing a syscall. SVN revision: 71988
This commit is contained in:
parent
8ece74f1fd
commit
491e44bb5f
|
@ -410,8 +410,17 @@ EAPI Eina_Bool
|
|||
eina_main_loop_is(void)
|
||||
{
|
||||
#ifdef EFL_HAVE_THREADS
|
||||
pid_t pid = getpid();
|
||||
pid_t pid;
|
||||
|
||||
# ifdef _WIN32
|
||||
if (_eina_main_loop == GetCurrentThreadId())
|
||||
return EINA_TRUE;
|
||||
# else
|
||||
if (pthread_equal(_eina_main_loop, pthread_self()))
|
||||
return EINA_TRUE;
|
||||
# endif
|
||||
|
||||
pid = getpid();
|
||||
# ifdef _WIN32
|
||||
if (pid != _eina_pid)
|
||||
{
|
||||
|
@ -419,9 +428,7 @@ eina_main_loop_is(void)
|
|||
_eina_main_loop = GetCurrentThreadId();
|
||||
return EINA_TRUE;
|
||||
}
|
||||
if (_eina_main_loop == GetCurrentThreadId())
|
||||
return EINA_TRUE;
|
||||
# else
|
||||
#else
|
||||
if (pid != _eina_pid)
|
||||
{
|
||||
/* This is in case of a fork, but don't like the solution */
|
||||
|
@ -429,11 +436,9 @@ eina_main_loop_is(void)
|
|||
_eina_main_loop = pthread_self();
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
if (pthread_equal(_eina_main_loop, pthread_self()))
|
||||
return EINA_TRUE;
|
||||
# endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue