ecore: correctly clean up in ecore_fork_reset

Summary:
after a fork does happen, the new process does not have any self created
threads at all. However, _thread_cb can contain suspend calls of
ecore_thread_main_loop_begin. _ecore_main_call_flush will then wait in
the suspend block for the thread to call ecore_thread_main_loop_end.
However, the thread is dead, the end function will never be called.
Hence we should ensure that we definitly kill every entry in _thread_cb
that has a susped flag on true.

This fixes deadlocks while running the testsuites with
EIO_MONITOR_POLL=1
Depends on D8526

Reviewers: cedric, segfaultxavi, zmike

Reviewed By: zmike

Subscribers: #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D8531
This commit is contained in:
Marcel Hollerbach 2019-04-02 08:50:54 -04:00 committed by Mike Blumenkrantz
parent 43a522b876
commit 2647d93177
1 changed files with 8 additions and 5 deletions

View File

@ -571,10 +571,13 @@ ecore_fork_reset(void)
EINA_LIST_FOREACH_SAFE(_thread_cb, l, ln, call)
{
if (call->suspend || call->sync) continue;
if (call->cb.async != (Ecore_Cb)&_ecore_thread_join) continue;
_thread_cb = eina_list_remove_list(_thread_cb, l);
free(call);
//if something is supsend, then the mainloop will be blocked until until thread is calling ecore_thread_main_loop_end()
//if something tries to join a thread as callback, ensure that we remove this
if (call->suspend || (call->cb.async == (Ecore_Cb)&_ecore_thread_join))
{
_thread_cb = eina_list_remove_list(_thread_cb, l);
free(call);
}
}
if (_thread_cb) ecore_pipe_write(_thread_call, &wakeup, sizeof (int));
}
@ -686,7 +689,7 @@ ecore_thread_main_loop_begin(void)
return ++_thread_loop;
}
order = malloc(sizeof (Ecore_Safe_Call));
order = calloc(1, sizeof (Ecore_Safe_Call));
if (!order) return -1;
eina_lock_take(&_thread_id_lock);