eldbus: Eldbus_Proxy require to handle self desctruction as refcounting doesn't fully protect.

Summary:
If the connection is destroyed before the proxy, the proxy will clear itself and self destroy.
Before that it will trigger the free callback to handle proper cleanup. Refcounting it doesn't
protect it from this self destruction scenario. So it is mandatory to always have a free callback
set on a proxy to handle its death properly.
Depends on D10286

Reviewers: zmike, bu5hm4n, segfaultxavi, stefan_schmidt, jsuya

Reviewed By: zmike

Subscribers: #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D10287
This commit is contained in:
Cedric BAIL 2019-10-07 10:04:05 -04:00 committed by Mike Blumenkrantz
parent e0187ce2ec
commit 7f91f6280d
1 changed files with 16 additions and 1 deletions

View File

@ -39,6 +39,14 @@ _eldbus_model_arguments_efl_object_constructor(Eo *obj, Eldbus_Model_Arguments_D
return efl_constructor(efl_super(obj, MY_CLASS));
}
static void
_cleanup_proxy_cb(void *data, const void *deadptr)
{
Eldbus_Model_Arguments_Data *pd = data;
if (pd->proxy == deadptr) pd->proxy = NULL;
}
static Efl_Object *
_eldbus_model_arguments_efl_object_finalize(Eo *obj, Eldbus_Model_Arguments_Data *pd)
{
@ -47,6 +55,8 @@ _eldbus_model_arguments_efl_object_finalize(Eo *obj, Eldbus_Model_Arguments_Data
eldbus_model_connection_set(obj,
eldbus_object_connection_get(eldbus_proxy_object_get(pd->proxy)));
eldbus_proxy_free_cb_add(pd->proxy, _cleanup_proxy_cb, pd);
return efl_finalize(efl_super(obj, MY_CLASS));
}
@ -73,7 +83,12 @@ _eldbus_model_arguments_efl_object_destructor(Eo *obj, Eldbus_Model_Arguments_Da
eina_hash_free(pd->properties);
eina_stringshare_del(pd->name);
eldbus_proxy_unref(pd->proxy);
if (pd->proxy)
{
eldbus_proxy_free_cb_del(pd->proxy, _cleanup_proxy_cb, pd);
eldbus_proxy_unref(pd->proxy);
pd->proxy = NULL;
}
efl_destructor(efl_super(obj, MY_CLASS));
}