diff options
author | Lucas De Marchi <lucas.demarchi@profusion.mobi> | 2013-01-15 14:33:48 +0000 |
---|---|---|
committer | Lucas De Marchi <lucas.demarchi@profusion.mobi> | 2013-01-15 14:33:48 +0000 |
commit | d4da99698e5ce80c64d9ba4617e40062f8bde50c (patch) | |
tree | d15620db5b1d7195f958274df8177ee57938c5b4 /src/lib | |
parent | ca0cc1cbc983954246e8e4a04dd7160301c2eb07 (diff) |
efl/edbus: make all edbus_*_send() methods unref its msg
There's no reason to keep a msg after it was sent. Before this patch we
had edbus_service_signal_send() unref'ing its msg and all the others
not. Also, several users (particularly the edbus_proxy_send() ones) were
forgetting to unref the msg.
This patch makes all these methods unref the message after it has been
succesfully sent:
- edbus_connection_send()
- edbus_object_send()
- edbus_proxy_send()
- edbus_service_signal_send()
SVN revision: 82807
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/edbus/edbus_freedesktop.c | 1 | ||||
-rw-r--r-- | src/lib/edbus/edbus_object.c | 3 | ||||
-rw-r--r-- | src/lib/edbus/edbus_pending.c | 12 | ||||
-rw-r--r-- | src/lib/edbus/edbus_proxy.c | 11 | ||||
-rw-r--r-- | src/lib/edbus/edbus_service.c | 9 | ||||
-rw-r--r-- | src/lib/efreet/efreet_cache.c | 3 | ||||
-rw-r--r-- | src/lib/ethumb/client/ethumb_client.c | 3 |
7 files changed, 17 insertions, 25 deletions
diff --git a/src/lib/edbus/edbus_freedesktop.c b/src/lib/edbus/edbus_freedesktop.c index bf5c50d3d3..716dcbcf22 100644 --- a/src/lib/edbus/edbus_freedesktop.c +++ b/src/lib/edbus/edbus_freedesktop.c | |||
@@ -78,6 +78,5 @@ edbus_object_managed_objects_get(EDBus_Object *obj, EDBus_Message_Cb cb, const v | |||
78 | msg = edbus_object_method_call_new(obj, EDBUS_FDO_INTERFACE_OBJECT_MANAGER, | 78 | msg = edbus_object_method_call_new(obj, EDBUS_FDO_INTERFACE_OBJECT_MANAGER, |
79 | "GetManagedObjects"); | 79 | "GetManagedObjects"); |
80 | p = edbus_object_send(obj, msg, cb, data, -1); | 80 | p = edbus_object_send(obj, msg, cb, data, -1); |
81 | edbus_message_unref(msg); | ||
82 | return p; | 81 | return p; |
83 | } | 82 | } |
diff --git a/src/lib/edbus/edbus_object.c b/src/lib/edbus/edbus_object.c index c887eb6056..d61a74a9ab 100644 --- a/src/lib/edbus/edbus_object.c +++ b/src/lib/edbus/edbus_object.c | |||
@@ -648,7 +648,6 @@ edbus_object_peer_ping(EDBus_Object *obj, EDBus_Message_Cb cb, const void *data) | |||
648 | EDBUS_OBJECT_CHECK_RETVAL(obj, NULL); | 648 | EDBUS_OBJECT_CHECK_RETVAL(obj, NULL); |
649 | msg = edbus_object_method_call_new(obj, EDBUS_FDO_INTEFACE_PEER, "Ping"); | 649 | msg = edbus_object_method_call_new(obj, EDBUS_FDO_INTEFACE_PEER, "Ping"); |
650 | p = edbus_object_send(obj, msg, cb, data, -1); | 650 | p = edbus_object_send(obj, msg, cb, data, -1); |
651 | edbus_message_unref(msg); | ||
652 | return p; | 651 | return p; |
653 | } | 652 | } |
654 | 653 | ||
@@ -661,7 +660,6 @@ edbus_object_peer_machine_id_get(EDBus_Object *obj, EDBus_Message_Cb cb, const v | |||
661 | msg = edbus_object_method_call_new(obj, EDBUS_FDO_INTEFACE_PEER, | 660 | msg = edbus_object_method_call_new(obj, EDBUS_FDO_INTEFACE_PEER, |
662 | "GetMachineId"); | 661 | "GetMachineId"); |
663 | p = edbus_object_send(obj, msg, cb, data, -1); | 662 | p = edbus_object_send(obj, msg, cb, data, -1); |
664 | edbus_message_unref(msg); | ||
665 | return p; | 663 | return p; |
666 | } | 664 | } |
667 | 665 | ||
@@ -674,6 +672,5 @@ edbus_object_introspect(EDBus_Object *obj, EDBus_Message_Cb cb, const void *data | |||
674 | msg = edbus_object_method_call_new(obj, EDBUS_FDO_INTERFACE_INTROSPECTABLE, | 672 | msg = edbus_object_method_call_new(obj, EDBUS_FDO_INTERFACE_INTROSPECTABLE, |
675 | "Introspect"); | 673 | "Introspect"); |
676 | p = edbus_object_send(obj, msg, cb, data, -1); | 674 | p = edbus_object_send(obj, msg, cb, data, -1); |
677 | edbus_message_unref(msg); | ||
678 | return p; | 675 | return p; |
679 | } | 676 | } |
diff --git a/src/lib/edbus/edbus_pending.c b/src/lib/edbus/edbus_pending.c index 99afc6f29f..bd609b240d 100644 --- a/src/lib/edbus/edbus_pending.c +++ b/src/lib/edbus/edbus_pending.c | |||
@@ -103,17 +103,22 @@ edbus_connection_send(EDBus_Connection *conn, EDBus_Message *msg, EDBus_Message_ | |||
103 | return pending; | 103 | return pending; |
104 | } | 104 | } |
105 | 105 | ||
106 | /* | ||
107 | * On success @param msg is unref'd or its ref is stolen by the returned | ||
108 | * EDBus_Pending. | ||
109 | */ | ||
106 | EDBus_Pending * | 110 | EDBus_Pending * |
107 | _edbus_connection_send(EDBus_Connection *conn, EDBus_Message *msg, EDBus_Message_Cb cb, const void *cb_data, double timeout) | 111 | _edbus_connection_send(EDBus_Connection *conn, EDBus_Message *msg, EDBus_Message_Cb cb, const void *cb_data, double timeout) |
108 | { | 112 | { |
109 | EDBus_Pending *pending; | 113 | EDBus_Pending *pending; |
110 | EDBus_Message *error_msg; | 114 | EDBus_Message *error_msg; |
111 | DBG("conn=%p, msg=%p, cb=%p, cb_data=%p, timeout=%f", | 115 | DBG("conn=%p, msg=%p, cb=%p, cb_data=%p, timeout=%f", |
112 | conn, msg, cb, cb_data, timeout); | 116 | conn, msg, cb, cb_data, timeout); |
113 | 117 | ||
114 | if (!cb) | 118 | if (!cb) |
115 | { | 119 | { |
116 | dbus_connection_send(conn->dbus_conn, msg->dbus_msg, NULL); | 120 | dbus_connection_send(conn->dbus_conn, msg->dbus_msg, NULL); |
121 | edbus_message_unref(msg); | ||
117 | return NULL; | 122 | return NULL; |
118 | } | 123 | } |
119 | 124 | ||
@@ -127,7 +132,10 @@ _edbus_connection_send(EDBus_Connection *conn, EDBus_Message *msg, EDBus_Message | |||
127 | pending->interface = eina_stringshare_add(dbus_message_get_interface(msg->dbus_msg)); | 132 | pending->interface = eina_stringshare_add(dbus_message_get_interface(msg->dbus_msg)); |
128 | pending->method = eina_stringshare_add(dbus_message_get_member(msg->dbus_msg)); | 133 | pending->method = eina_stringshare_add(dbus_message_get_member(msg->dbus_msg)); |
129 | pending->path = eina_stringshare_add(dbus_message_get_path(msg->dbus_msg)); | 134 | pending->path = eina_stringshare_add(dbus_message_get_path(msg->dbus_msg)); |
130 | pending->msg_sent = edbus_message_ref(msg); | 135 | |
136 | /* Steal the reference */ | ||
137 | pending->msg_sent = msg; | ||
138 | |||
131 | EINA_MAGIC_SET(pending, EDBUS_PENDING_MAGIC); | 139 | EINA_MAGIC_SET(pending, EDBUS_PENDING_MAGIC); |
132 | 140 | ||
133 | if (!dbus_connection_send_with_reply(conn->dbus_conn, | 141 | if (!dbus_connection_send_with_reply(conn->dbus_conn, |
diff --git a/src/lib/edbus/edbus_proxy.c b/src/lib/edbus/edbus_proxy.c index c90b91bd0c..c59a031877 100644 --- a/src/lib/edbus/edbus_proxy.c +++ b/src/lib/edbus/edbus_proxy.c | |||
@@ -539,7 +539,6 @@ edbus_proxy_method_call_new(EDBus_Proxy *proxy, const char *member) | |||
539 | static EDBus_Pending * | 539 | static EDBus_Pending * |
540 | _edbus_proxy_vcall(EDBus_Proxy *proxy, const char *member, EDBus_Message_Cb cb, const void *cb_data, double timeout, const char *signature, va_list ap) | 540 | _edbus_proxy_vcall(EDBus_Proxy *proxy, const char *member, EDBus_Message_Cb cb, const void *cb_data, double timeout, const char *signature, va_list ap) |
541 | { | 541 | { |
542 | EDBus_Pending *pending; | ||
543 | EDBus_Message *msg = edbus_proxy_method_call_new(proxy, member); | 542 | EDBus_Message *msg = edbus_proxy_method_call_new(proxy, member); |
544 | EINA_SAFETY_ON_NULL_RETURN_VAL(msg, NULL); | 543 | EINA_SAFETY_ON_NULL_RETURN_VAL(msg, NULL); |
545 | 544 | ||
@@ -550,9 +549,7 @@ _edbus_proxy_vcall(EDBus_Proxy *proxy, const char *member, EDBus_Message_Cb cb, | |||
550 | return NULL; | 549 | return NULL; |
551 | } | 550 | } |
552 | 551 | ||
553 | pending = _edbus_proxy_send(proxy, msg, cb, cb_data, timeout); | 552 | return _edbus_proxy_send(proxy, msg, cb, cb_data, timeout); |
554 | edbus_message_unref(msg); | ||
555 | return pending; | ||
556 | } | 553 | } |
557 | 554 | ||
558 | EAPI EDBus_Pending * | 555 | EAPI EDBus_Pending * |
@@ -628,7 +625,6 @@ edbus_proxy_property_set(EDBus_Proxy *proxy, const char *name, const char *sig, | |||
628 | { | 625 | { |
629 | EDBus_Message *msg; | 626 | EDBus_Message *msg; |
630 | EDBus_Message_Iter *iter, *variant; | 627 | EDBus_Message_Iter *iter, *variant; |
631 | EDBus_Pending *pending; | ||
632 | 628 | ||
633 | EDBUS_PROXY_CHECK_RETVAL(proxy, NULL); | 629 | EDBUS_PROXY_CHECK_RETVAL(proxy, NULL); |
634 | EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL); | 630 | EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL); |
@@ -653,10 +649,7 @@ edbus_proxy_property_set(EDBus_Proxy *proxy, const char *name, const char *sig, | |||
653 | } | 649 | } |
654 | edbus_message_iter_container_close(iter, variant); | 650 | edbus_message_iter_container_close(iter, variant); |
655 | 651 | ||
656 | pending = edbus_proxy_send(proxy->obj->properties, msg, cb, data, -1); | 652 | return edbus_proxy_send(proxy->obj->properties, msg, cb, data, -1); |
657 | edbus_message_unref(msg); | ||
658 | |||
659 | return pending; | ||
660 | } | 653 | } |
661 | 654 | ||
662 | EAPI EDBus_Pending * | 655 | EAPI EDBus_Pending * |
diff --git a/src/lib/edbus/edbus_service.c b/src/lib/edbus/edbus_service.c index e83d7a48bb..d1fd8d4eee 100644 --- a/src/lib/edbus/edbus_service.c +++ b/src/lib/edbus/edbus_service.c | |||
@@ -729,11 +729,13 @@ _iface_changed_send(void *data) | |||
729 | ERR("msg == NULL"); | 729 | ERR("msg == NULL"); |
730 | continue; | 730 | continue; |
731 | } | 731 | } |
732 | |||
732 | main_iter = edbus_message_iter_get(msg); | 733 | main_iter = edbus_message_iter_get(msg); |
733 | edbus_message_iter_arguments_append(main_iter, "oa{sa{sv}}", | 734 | edbus_message_iter_arguments_append(main_iter, "oa{sa{sv}}", |
734 | iface->obj->path, &array_iface); | 735 | iface->obj->path, &array_iface); |
735 | if (!_propmgr_iface_props_append(iface, array_iface)) | 736 | if (!_propmgr_iface_props_append(iface, array_iface)) |
736 | goto error; | 737 | goto error; |
738 | |||
737 | EINA_LIST_FOREACH_SAFE(parent->iface_added, l, l2, next_iface) | 739 | EINA_LIST_FOREACH_SAFE(parent->iface_added, l, l2, next_iface) |
738 | { | 740 | { |
739 | if (iface->obj->path != next_iface->obj->path) | 741 | if (iface->obj->path != next_iface->obj->path) |
@@ -747,6 +749,7 @@ _iface_changed_send(void *data) | |||
747 | edbus_message_iter_container_close(main_iter, array_iface); | 749 | edbus_message_iter_container_close(main_iter, array_iface); |
748 | edbus_connection_send(parent->conn, msg, NULL, NULL, -1); | 750 | edbus_connection_send(parent->conn, msg, NULL, NULL, -1); |
749 | continue; | 751 | continue; |
752 | |||
750 | error: | 753 | error: |
751 | ERR("Error appending InterfacesAdded to msg."); | 754 | ERR("Error appending InterfacesAdded to msg."); |
752 | edbus_message_unref(msg); | 755 | edbus_message_unref(msg); |
@@ -770,7 +773,7 @@ error: | |||
770 | main_iter = edbus_message_iter_get(msg); | 773 | main_iter = edbus_message_iter_get(msg); |
771 | 774 | ||
772 | edbus_message_iter_arguments_append(main_iter, "oas", iface_data->obj_path, | 775 | edbus_message_iter_arguments_append(main_iter, "oas", iface_data->obj_path, |
773 | &array_iface); | 776 | &array_iface); |
774 | edbus_message_iter_basic_append(array_iface, 's', iface_data->iface); | 777 | edbus_message_iter_basic_append(array_iface, 's', iface_data->iface); |
775 | 778 | ||
776 | EINA_LIST_FOREACH_SAFE(parent->iface_removed, l, l2, iface_data_next) | 779 | EINA_LIST_FOREACH_SAFE(parent->iface_removed, l, l2, iface_data_next) |
@@ -1196,7 +1199,6 @@ _object_handler(DBusConnection *conn EINA_UNUSED, DBusMessage *msg, void *user_d | |||
1196 | if (!reply) return DBUS_HANDLER_RESULT_HANDLED; | 1199 | if (!reply) return DBUS_HANDLER_RESULT_HANDLED; |
1197 | 1200 | ||
1198 | _edbus_connection_send(obj->conn, reply, NULL, NULL, -1); | 1201 | _edbus_connection_send(obj->conn, reply, NULL, NULL, -1); |
1199 | edbus_message_unref(reply); | ||
1200 | 1202 | ||
1201 | return DBUS_HANDLER_RESULT_HANDLED; | 1203 | return DBUS_HANDLER_RESULT_HANDLED; |
1202 | } | 1204 | } |
@@ -1259,7 +1261,6 @@ edbus_service_signal_send(const EDBus_Service_Interface *iface, EDBus_Message *s | |||
1259 | EDBUS_SERVICE_INTERFACE_CHECK_RETVAL(iface, EINA_FALSE); | 1261 | EDBUS_SERVICE_INTERFACE_CHECK_RETVAL(iface, EINA_FALSE); |
1260 | EINA_SAFETY_ON_NULL_RETURN_VAL(signal_msg, EINA_FALSE); | 1262 | EINA_SAFETY_ON_NULL_RETURN_VAL(signal_msg, EINA_FALSE); |
1261 | _edbus_connection_send(iface->obj->conn, signal_msg, NULL, NULL, -1); | 1263 | _edbus_connection_send(iface->obj->conn, signal_msg, NULL, NULL, -1); |
1262 | edbus_message_unref(signal_msg); | ||
1263 | return EINA_TRUE; | 1264 | return EINA_TRUE; |
1264 | } | 1265 | } |
1265 | 1266 | ||
diff --git a/src/lib/efreet/efreet_cache.c b/src/lib/efreet/efreet_cache.c index 6e99ee3951..5c3a52a669 100644 --- a/src/lib/efreet/efreet_cache.c +++ b/src/lib/efreet/efreet_cache.c | |||
@@ -878,7 +878,6 @@ efreet_cache_desktop_add(Efreet_Desktop *desktop) | |||
878 | edbus_message_iter_basic_append(array_of_string, 's', path); | 878 | edbus_message_iter_basic_append(array_of_string, 's', path); |
879 | edbus_message_iter_container_close(iter, array_of_string); | 879 | edbus_message_iter_container_close(iter, array_of_string); |
880 | edbus_proxy_send(proxy, msg, NULL, NULL, -1); | 880 | edbus_proxy_send(proxy, msg, NULL, NULL, -1); |
881 | edbus_message_unref(msg); | ||
882 | free(path); | 881 | free(path); |
883 | } | 882 | } |
884 | 883 | ||
@@ -898,7 +897,6 @@ efreet_cache_icon_exts_add(Eina_List *exts) | |||
898 | edbus_message_iter_basic_append(array_of_string, 's', ext); | 897 | edbus_message_iter_basic_append(array_of_string, 's', ext); |
899 | edbus_message_iter_container_close(iter, array_of_string); | 898 | edbus_message_iter_container_close(iter, array_of_string); |
900 | edbus_proxy_send(proxy, msg, NULL, NULL, -1); | 899 | edbus_proxy_send(proxy, msg, NULL, NULL, -1); |
901 | edbus_message_unref(msg); | ||
902 | } | 900 | } |
903 | 901 | ||
904 | void | 902 | void |
@@ -917,7 +915,6 @@ efreet_cache_icon_dirs_add(Eina_List *dirs) | |||
917 | edbus_message_iter_basic_append(array_of_string, 's', dir); | 915 | edbus_message_iter_basic_append(array_of_string, 's', dir); |
918 | edbus_message_iter_container_close(iter, array_of_string); | 916 | edbus_message_iter_container_close(iter, array_of_string); |
919 | edbus_proxy_send(proxy, msg, NULL, NULL, -1); | 917 | edbus_proxy_send(proxy, msg, NULL, NULL, -1); |
920 | edbus_message_unref(msg); | ||
921 | } | 918 | } |
922 | 919 | ||
923 | void | 920 | void |
diff --git a/src/lib/ethumb/client/ethumb_client.c b/src/lib/ethumb/client/ethumb_client.c index cfe04887cf..9c2530323c 100644 --- a/src/lib/ethumb/client/ethumb_client.c +++ b/src/lib/ethumb/client/ethumb_client.c | |||
@@ -353,7 +353,6 @@ _ethumb_client_call_new(Ethumb_Client *client) | |||
353 | _ethumb_dbus_path, | 353 | _ethumb_dbus_path, |
354 | _ethumb_dbus_interface, "new"); | 354 | _ethumb_dbus_interface, "new"); |
355 | edbus_connection_send(client->conn, msg, _ethumb_client_new_cb, client, -1); | 355 | edbus_connection_send(client->conn, msg, _ethumb_client_new_cb, client, -1); |
356 | edbus_message_unref(msg); | ||
357 | } | 356 | } |
358 | 357 | ||
359 | static void | 358 | static void |
@@ -822,7 +821,6 @@ ethumb_client_ethumb_setup(Ethumb_Client *client) | |||
822 | 821 | ||
823 | edbus_proxy_send(client->proxy, msg, _ethumb_client_ethumb_setup_cb, | 822 | edbus_proxy_send(client->proxy, msg, _ethumb_client_ethumb_setup_cb, |
824 | client, -1); | 823 | client, -1); |
825 | edbus_message_unref(msg); | ||
826 | } | 824 | } |
827 | 825 | ||
828 | /** | 826 | /** |
@@ -962,7 +960,6 @@ _ethumb_client_queue_add(Ethumb_Client *client, const char *file, const char *ke | |||
962 | _ethumb_client_queue_add_cb, | 960 | _ethumb_client_queue_add_cb, |
963 | pending, -1); | 961 | pending, -1); |
964 | client->pending_add = eina_list_append(client->pending_add, pending); | 962 | client->pending_add = eina_list_append(client->pending_add, pending); |
965 | edbus_message_unref(msg); | ||
966 | 963 | ||
967 | return pending->id; | 964 | return pending->id; |
968 | } | 965 | } |