summaryrefslogtreecommitdiff
path: root/src/lib/eina
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2019-03-13 14:49:50 -0700
committerCedric BAIL <cedric.bail@free.fr>2019-03-27 15:03:08 -0700
commite859130dd47ee503a8691ca15b5b4255b02a3bb7 (patch)
tree3ab71a58723f24ee9dabf92ee1fd79d04690dc6d /src/lib/eina
parent6b6faef3a359f453b04a3783b7e3633f3db314c6 (diff)
eina: prevent double cancel of ongoing dispatched future.
Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de> Differential Revision: https://phab.enlightenment.org/D8333
Diffstat (limited to 'src/lib/eina')
-rw-r--r--src/lib/eina/eina_promise.c13
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)
333{ 333{
334 Eina_Future_Cb cb = f->cb; 334 Eina_Future_Cb cb = f->cb;
335 335
336 // Cleaning up prev and past to avoid recursion
337 if (f->next) f->next->prev = NULL;
338 if (f->prev) f->prev->next = NULL;
339
336 f->cb = EINA_FUTURE_DISPATCHED; 340 f->cb = EINA_FUTURE_DISPATCHED;
337 if (f->storage) *f->storage = NULL; 341 if (f->storage) *f->storage = NULL;
338 342
@@ -364,6 +368,7 @@ _eina_future_dispatch_internal(Eina_Future **f,
364 _eina_promise_value_dbg("No future to deliver value", NULL, value); 368 _eina_promise_value_dbg("No future to deliver value", NULL, value);
365 return value; 369 return value;
366 } 370 }
371 if ((*f)->cb == EINA_FUTURE_DISPATCHED) return value;
367 next_value = _eina_future_cb_dispatch(*f, value); 372 next_value = _eina_future_cb_dispatch(*f, value);
368 *f = _eina_future_free(*f); 373 *f = _eina_future_free(*f);
369 return next_value; 374 return next_value;
@@ -396,6 +401,12 @@ _eina_future_dispatch(Eina_Future_Scheduler *scheduler, Eina_Future *f, Eina_Val
396 return; 401 return;
397 } 402 }
398 403
404 // Break early if finding a cb that is already dispatching
405 if (f->cb == EINA_FUTURE_DISPATCHED)
406 {
407 eina_value_flush(&next_value);
408 return;
409 }
399 if (next_value.type == &EINA_VALUE_TYPE_PROMISE) 410 if (next_value.type == &EINA_VALUE_TYPE_PROMISE)
400 { 411 {
401 if (EINA_UNLIKELY(eina_log_domain_level_check(_promise_log_dom, EINA_LOG_LEVEL_DBG))) 412 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)
463 474
464 while (f) 475 while (f)
465 { 476 {
477 // Stop on partially dispatched future
478 if (f->cb == EINA_FUTURE_DISPATCHED) break;
466 if (f->cb) 479 if (f->cb)
467 { 480 {
468 Eina_Value r = _eina_future_cb_dispatch(f, value); 481 Eina_Value r = _eina_future_cb_dispatch(f, value);