From b0be69999be761f6619cf4ca91b87fed62af3153 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Andre Date: Fri, 15 Dec 2017 17:44:28 +0900 Subject: [PATCH] eo/eina: Add HACK to avoid calls to EO after shutdown Efl.Future is an EO object which means even cancelling Efl.Future objects requires EO. So this should be done before shutting down EO, otherwise everything fails badly. I believe Efl.Future is going to disappear soon, but the problem will remain: if any promise/future uses EO or anything else outside of Eina (so, basically anything) then it needs to be canceled before shutting down the above layers. This is the same situation as with ecore events, for which we've introduced ecore_event_type_flush. Ping @cedric --- src/lib/eina/eina_promise.c | 9 ++++++++- src/lib/eina/eina_promise.h | 8 ++++++++ src/lib/eo/efl_future.c | 1 + 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/lib/eina/eina_promise.c b/src/lib/eina/eina_promise.c index 649b6e9..7e7617c 100644 --- a/src/lib/eina/eina_promise.c +++ b/src/lib/eina/eina_promise.c @@ -532,10 +532,17 @@ eina_promise_init(void) return EINA_FALSE; } +EAPI void +__eina_promise_cancel_all(void) +{ + while (_pending_futures) + _eina_future_cancel(_pending_futures->data, ECANCELED); +} + Eina_Bool eina_promise_shutdown(void) { - while (_pending_futures) _eina_future_cancel(_pending_futures->data, ECANCELED); + __eina_promise_cancel_all(); eina_mempool_del(_future_mp); eina_mempool_del(_promise_mp); eina_log_domain_unregister(_promise_log_dom); diff --git a/src/lib/eina/eina_promise.h b/src/lib/eina/eina_promise.h index 44e9aef..41778c5 100644 --- a/src/lib/eina/eina_promise.h +++ b/src/lib/eina/eina_promise.h @@ -1736,6 +1736,14 @@ eina_future_race_array(Eina_Future *array[]) */ #define eina_future_chain_easy(_prev, ...) eina_future_chain_easy_array(_prev, (Eina_Future_Cb_Easy_Desc[]) {__VA_ARGS__, {NULL, NULL, NULL, NULL, NULL}}) +/** + * @brief Cancels all pending promise/futures. + * + * Internal function. Do not use. + * + * @internal + */ +EAPI void __eina_promise_cancel_all(void); /** * @} diff --git a/src/lib/eo/efl_future.c b/src/lib/eo/efl_future.c index aaa1d88..8f19a34 100644 --- a/src/lib/eo/efl_future.c +++ b/src/lib/eo/efl_future.c @@ -52,5 +52,6 @@ efl_future_init(void) Eina_Bool efl_future_shutdown(void) { + __eina_promise_cancel_all(); return EINA_TRUE; } -- 2.7.4