summaryrefslogtreecommitdiff
path: root/src/lib/eldbus
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2019-10-07 10:04:05 -0400
committerMike Blumenkrantz <zmike@samsung.com>2019-10-07 10:04:05 -0400
commit7f91f6280d103c2c5148276b438adf5bbdcf373d (patch)
treea4f82f0b2982637cdfc06b3244a6424e12c10d77 /src/lib/eldbus
parente0187ce2ec409ceabf93664a0c6a4105676b2e66 (diff)
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
Diffstat (limited to 'src/lib/eldbus')
-rw-r--r--src/lib/eldbus/eldbus_model_arguments.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/lib/eldbus/eldbus_model_arguments.c b/src/lib/eldbus/eldbus_model_arguments.c
index ed6cbe2..ca0b6d6 100644
--- a/src/lib/eldbus/eldbus_model_arguments.c
+++ b/src/lib/eldbus/eldbus_model_arguments.c
@@ -39,6 +39,14 @@ _eldbus_model_arguments_efl_object_constructor(Eo *obj, Eldbus_Model_Arguments_D
39 return efl_constructor(efl_super(obj, MY_CLASS)); 39 return efl_constructor(efl_super(obj, MY_CLASS));
40} 40}
41 41
42static void
43_cleanup_proxy_cb(void *data, const void *deadptr)
44{
45 Eldbus_Model_Arguments_Data *pd = data;
46
47 if (pd->proxy == deadptr) pd->proxy = NULL;
48}
49
42static Efl_Object * 50static Efl_Object *
43_eldbus_model_arguments_efl_object_finalize(Eo *obj, Eldbus_Model_Arguments_Data *pd) 51_eldbus_model_arguments_efl_object_finalize(Eo *obj, Eldbus_Model_Arguments_Data *pd)
44{ 52{
@@ -47,6 +55,8 @@ _eldbus_model_arguments_efl_object_finalize(Eo *obj, Eldbus_Model_Arguments_Data
47 eldbus_model_connection_set(obj, 55 eldbus_model_connection_set(obj,
48 eldbus_object_connection_get(eldbus_proxy_object_get(pd->proxy))); 56 eldbus_object_connection_get(eldbus_proxy_object_get(pd->proxy)));
49 57
58 eldbus_proxy_free_cb_add(pd->proxy, _cleanup_proxy_cb, pd);
59
50 return efl_finalize(efl_super(obj, MY_CLASS)); 60 return efl_finalize(efl_super(obj, MY_CLASS));
51} 61}
52 62
@@ -73,7 +83,12 @@ _eldbus_model_arguments_efl_object_destructor(Eo *obj, Eldbus_Model_Arguments_Da
73 eina_hash_free(pd->properties); 83 eina_hash_free(pd->properties);
74 84
75 eina_stringshare_del(pd->name); 85 eina_stringshare_del(pd->name);
76 eldbus_proxy_unref(pd->proxy); 86 if (pd->proxy)
87 {
88 eldbus_proxy_free_cb_del(pd->proxy, _cleanup_proxy_cb, pd);
89 eldbus_proxy_unref(pd->proxy);
90 pd->proxy = NULL;
91 }
77 92
78 efl_destructor(efl_super(obj, MY_CLASS)); 93 efl_destructor(efl_super(obj, MY_CLASS));
79} 94}