summaryrefslogtreecommitdiff
path: root/src/lib/ecore_con
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2019-01-04 16:01:13 -0800
committerCedric BAIL <cedric.bail@free.fr>2019-01-16 14:33:14 -0800
commit54729224672db79ff2ec09307ac862ddf494f131 (patch)
treedf50db929a571f05a964542a3eaf440a45984d57 /src/lib/ecore_con
parent4e4176c84c3bd227301d8de5dfa2bac4ba002f40 (diff)
ecore_con: remove use of eina_promise_data_set.
eina_promise_data_set is a misleading API and result in conflicted use by multiple independent piece of code leading to bug and crash. It is also not necessary and we can avoid using it completely. Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Differential Revision: https://phab.enlightenment.org/D7545
Diffstat (limited to 'src/lib/ecore_con')
-rw-r--r--src/lib/ecore_con/efl_net_control_technology-connman.c41
1 files changed, 22 insertions, 19 deletions
diff --git a/src/lib/ecore_con/efl_net_control_technology-connman.c b/src/lib/ecore_con/efl_net_control_technology-connman.c
index 2ccec1d..5b2af8c 100644
--- a/src/lib/ecore_con/efl_net_control_technology-connman.c
+++ b/src/lib/ecore_con/efl_net_control_technology-connman.c
@@ -348,15 +348,11 @@ static void
348_efl_net_control_technology_scan_cb(void *data, const Eldbus_Message *msg, Eldbus_Pending *pending) 348_efl_net_control_technology_scan_cb(void *data, const Eldbus_Message *msg, Eldbus_Pending *pending)
349{ 349{
350 Eina_Promise *promise = data; 350 Eina_Promise *promise = data;
351 Eo *o = eldbus_pending_data_get(eina_promise_data_get(promise), ".object");
352 Efl_Net_Control_Technology_Data *pd = efl_data_scope_get(o, MY_CLASS);
353 const char *err_name, *err_msg; 351 const char *err_name, *err_msg;
354 352
355 EINA_SAFETY_ON_NULL_RETURN(pd);
356
357 pd->pending = eina_list_remove(pd->pending, pending);
358 if (eldbus_message_error_get(msg, &err_name, &err_msg)) 353 if (eldbus_message_error_get(msg, &err_name, &err_msg))
359 { 354 {
355 Eo *o = eldbus_pending_data_get(pending, ".object");
360 Eina_Error err = EINVAL; 356 Eina_Error err = EINVAL;
361 357
362 if (strcmp(err_name, "net.connman.Error.NotSupported") == 0) 358 if (strcmp(err_name, "net.connman.Error.NotSupported") == 0)
@@ -370,24 +366,29 @@ _efl_net_control_technology_scan_cb(void *data, const Eldbus_Message *msg, Eldbu
370 eina_promise_resolve(promise, EINA_VALUE_EMPTY); 366 eina_promise_resolve(promise, EINA_VALUE_EMPTY);
371} 367}
372 368
369static Eina_Value
370_efl_net_control_technology_scan_promise_cancel(Eo *o EINA_UNUSED, void *data, Eina_Error error)
371{
372 Eldbus_Pending *p = data;
373
374 if (error == ECANCELED)
375 {
376 DBG("cancel pending scan %p", p);
377 eldbus_pending_cancel(p);
378 }
379
380 return eina_value_error_init(error);
381}
382
373static void 383static void
374_efl_net_control_technology_scan_promise_del(void *data EINA_UNUSED, Efl_Loop_Consumer *consumer EINA_UNUSED, const Eina_Promise *dead_ptr) 384_efl_net_control_technology_scan_promise_del(Eo *o, void *data, const Eina_Future *dead_future EINA_UNUSED)
375{ 385{
376 Eldbus_Pending *p; 386 Eldbus_Pending *p = data;
377 Efl_Net_Control_Technology_Data *pd; 387 Efl_Net_Control_Technology_Data *pd;
378 Eo *o;
379 388
380 p = eina_promise_data_get(dead_ptr);
381 if (!p) return; /* already gone, nothing to do */
382
383 o = eldbus_pending_data_get(p, ".object");
384 pd = efl_data_scope_get(o, MY_CLASS); 389 pd = efl_data_scope_get(o, MY_CLASS);
385 390
386 EINA_SAFETY_ON_NULL_RETURN(pd);
387
388 pd->pending = eina_list_remove(pd->pending, p); 391 pd->pending = eina_list_remove(pd->pending, p);
389 DBG("cancel pending scan %p", p);
390 eldbus_pending_cancel(p);
391} 392}
392 393
393EOLIAN static Eina_Future * 394EOLIAN static Eina_Future *
@@ -397,7 +398,7 @@ _efl_net_control_technology_scan(Eo *o, Efl_Net_Control_Technology_Data *pd)
397 Eina_Promise *promise; 398 Eina_Promise *promise;
398 Eina_Future *f = NULL; 399 Eina_Future *f = NULL;
399 400
400 promise = efl_loop_promise_new(o, NULL, _efl_net_control_technology_scan_promise_del, NULL); 401 promise = efl_loop_promise_new(o, NULL, NULL, NULL);
401 EINA_SAFETY_ON_NULL_RETURN_VAL(promise, NULL); 402 EINA_SAFETY_ON_NULL_RETURN_VAL(promise, NULL);
402 403
403 f = eina_future_new(promise); 404 f = eina_future_new(promise);
@@ -407,10 +408,12 @@ _efl_net_control_technology_scan(Eo *o, Efl_Net_Control_Technology_Data *pd)
407 EINA_SAFETY_ON_NULL_GOTO(p, error_dbus); 408 EINA_SAFETY_ON_NULL_GOTO(p, error_dbus);
408 409
409 pd->pending = eina_list_append(pd->pending, p); 410 pd->pending = eina_list_append(pd->pending, p);
410 eina_promise_data_set(promise, p);
411 eldbus_pending_data_set(p, ".object", o); 411 eldbus_pending_data_set(p, ".object", o);
412 412
413 return efl_future_then(o, f); 413 return efl_future_then(o, f,
414 .error = _efl_net_control_technology_scan_promise_cancel,
415 .free = _efl_net_control_technology_scan_promise_del,
416 .data = p);
414 417
415 error_dbus: 418 error_dbus:
416 eina_promise_reject(promise, ENOSYS); 419 eina_promise_reject(promise, ENOSYS);