diff options
author | Cedric BAIL <cedric.bail@free.fr> | 2019-03-13 14:49:50 -0700 |
---|---|---|
committer | Cedric BAIL <cedric.bail@free.fr> | 2019-03-27 15:03:08 -0700 |
commit | e859130dd47ee503a8691ca15b5b4255b02a3bb7 (patch) | |
tree | 3ab71a58723f24ee9dabf92ee1fd79d04690dc6d | |
parent | 6b6faef3a359f453b04a3783b7e3633f3db314c6 (diff) | |
download | efl-e859130dd47ee503a8691ca15b5b4255b02a3bb7.tar.gz |
eina: prevent double cancel of ongoing dispatched future.
Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de>
Differential Revision: https://phab.enlightenment.org/D8333
-rw-r--r-- | src/lib/eina/eina_promise.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/lib/eina/eina_promise.c b/src/lib/eina/eina_promise.c index 62a47576ce..a5f5c40b5a 100644 --- a/src/lib/eina/eina_promise.c +++ b/src/lib/eina/eina_promise.c @@ -333,6 +333,10 @@ _eina_future_cb_dispatch(Eina_Future *f, const Eina_Value value) { Eina_Future_Cb cb = f->cb; + // Cleaning up prev and past to avoid recursion + if (f->next) f->next->prev = NULL; + if (f->prev) f->prev->next = NULL; + f->cb = EINA_FUTURE_DISPATCHED; if (f->storage) *f->storage = NULL; @@ -364,6 +368,7 @@ _eina_future_dispatch_internal(Eina_Future **f, _eina_promise_value_dbg("No future to deliver value", NULL, value); return value; } + if ((*f)->cb == EINA_FUTURE_DISPATCHED) return value; next_value = _eina_future_cb_dispatch(*f, value); *f = _eina_future_free(*f); return next_value; @@ -396,6 +401,12 @@ _eina_future_dispatch(Eina_Future_Scheduler *scheduler, Eina_Future *f, Eina_Val return; } + // Break early if finding a cb that is already dispatching + if (f->cb == EINA_FUTURE_DISPATCHED) + { + eina_value_flush(&next_value); + return; + } if (next_value.type == &EINA_VALUE_TYPE_PROMISE) { if (EINA_UNLIKELY(eina_log_domain_level_check(_promise_log_dom, EINA_LOG_LEVEL_DBG))) @@ -463,6 +474,8 @@ _eina_future_cancel(Eina_Future *f, int err) while (f) { + // Stop on partially dispatched future + if (f->cb == EINA_FUTURE_DISPATCHED) break; if (f->cb) { Eina_Value r = _eina_future_cb_dispatch(f, value); |