raster pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=0a3e7c05e42eb4b46c782c37b430f427a0902169
commit 0a3e7c05e42eb4b46c782c37b430f427a0902169 Author: Carsten Haitzler (Rasterman) <ras...@rasterman.com> Date: Mon Mar 26 20:53:06 2018 +0900 ecore - efl exe + thread - error print if deleted before task is done both exe and thread objects must (currently) stay around until the child thread or exe (task) is done. if you don't do this "bad things can happen". so produce an error to let the programmer know. --- src/lib/ecore/efl_exe.c | 7 +++++-- src/lib/ecore/efl_thread.c | 38 +++++--------------------------------- 2 files changed, 10 insertions(+), 35 deletions(-) diff --git a/src/lib/ecore/efl_exe.c b/src/lib/ecore/efl_exe.c index 581c570100..01e7497977 100644 --- a/src/lib/ecore/efl_exe.c +++ b/src/lib/ecore/efl_exe.c @@ -190,10 +190,11 @@ _exe_exit_eval(Eo *obj, Efl_Exe_Data *pd) pd->exit_called = EINA_TRUE; if (pd->promise) { + Eina_Promise *p = pd->promise; int exit_code = efl_task_exit_code_get(obj); - if (exit_code != 0) eina_promise_reject(pd->promise, exit_code + 1000000); - else eina_promise_resolve(pd->promise, eina_value_int_init(0)); pd->promise = NULL; + if (exit_code != 0) eina_promise_reject(p, exit_code + 1000000); + else eina_promise_resolve(p, eina_value_int_init(0)); } } } @@ -575,6 +576,8 @@ _efl_exe_efl_object_destructor(Eo *obj, Efl_Exe_Data *pd) { #ifdef _WIN32 #else + if (pd->promise) + ERR("Exe being destroyed while child has not exited yet."); if (pd->fd.exited_read >= 0) { _ecore_signal_pid_lock(); diff --git a/src/lib/ecore/efl_thread.c b/src/lib/ecore/efl_thread.c index 91e7ddb3f0..0a0e469a00 100644 --- a/src/lib/ecore/efl_thread.c +++ b/src/lib/ecore/efl_thread.c @@ -320,10 +320,11 @@ _thread_exit_eval(Eo *obj, Efl_Thread_Data *pd) if (pd->thdat) efl_threadio_outdata_set(obj, pd->thdat->outdata); if (pd->promise) { + Eina_Promise *p = pd->promise; int exit_code = efl_task_exit_code_get(obj); - if (exit_code != 0) eina_promise_reject(pd->promise, exit_code + 1000000); - else eina_promise_resolve(pd->promise, eina_value_int_init(0)); pd->promise = NULL; + if (exit_code != 0) eina_promise_reject(p, exit_code + 1000000); + else eina_promise_resolve(p, eina_value_int_init(0)); } } } @@ -506,39 +507,10 @@ _efl_thread_efl_object_constructor(Eo *obj, Efl_Thread_Data *pd) EOLIAN static void _efl_thread_efl_object_destructor(Eo *obj, Efl_Thread_Data *pd) { + if (pd->promise) + ERR("Thread being destroyed while real worker has not exited yet."); if (pd->thdat) { -/* we probably shouldn't do this... this simply has to orphan threads if they - * lose their parent. this stops shutdown from blocking. - // if exit response not read yet, read until fetched - if (!pd->exit_read) - { - Control_Data cmd; - ssize_t ret; - - // if it hasn't been asked to exit... ask it - if (!pd->end_sent) efl_task_end(obj); - memset(&cmd, 0, sizeof(cmd)); - ret = read(pd->ctrl.out, &cmd, sizeof(Control_Data)); - while (ret == sizeof(Control_Data)) - { - if (cmd.d.command == CMD_EXITED) - { - if (!pd->exit_read) - { - Efl_Task_Data *td = efl_data_scope_get(obj, EFL_TASK_CLASS); - - if (td) td->exit_code = cmd.d.data; - pd->exit_read = EINA_TRUE; - efl_event_callback_call(obj, EFL_TASK_EVENT_EXIT, NULL); - break; - } - } - ret = read(pd->ctrl.out, &cmd, sizeof(Control_Data)); - } - } - */ - // stop and wait for thread to exit/join here eina_thread_join(pd->thread); efl_del(pd->fd.in_handler); efl_del(pd->fd.out_handler); --