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
This commit is contained in:
Lucas De Marchi 2013-01-15 14:33:48 +00:00
parent ca0cc1cbc9
commit d4da99698e
10 changed files with 17 additions and 32 deletions

View File

@ -291,14 +291,12 @@ main(void)
msg = edbus_proxy_method_call_new(proxy, "ReceiveArrayOfStringIntWithSize");
_fill_receive_array_of_string_int_with_size(msg, size_of_array, array_string);
edbus_proxy_send(proxy, msg, on_receive_array_with_size, NULL, -1);
edbus_message_unref(msg);
edbus_proxy_call(proxy, "SendArray", on_send_array, NULL, -1 , "");
msg = edbus_proxy_method_call_new(proxy, "PlusOne");
_fill_plus_one(msg, 14);
edbus_proxy_send(proxy, msg, on_plus_one, NULL, -1);
edbus_message_unref(msg);
edbus_proxy_event_callback_add(proxy,
EDBUS_PROXY_EVENT_PROPERTY_CHANGED,

View File

@ -211,7 +211,6 @@ main(void)
edbus_message_iter_container_close(iter, array_of_string);
pending = edbus_proxy_send(test2_proxy, msg, on_receive_array, NULL, -1);
if (!pending) printf("Error in edbus_proxy_send()\n\n");
edbus_message_unref(msg);
msg = edbus_proxy_method_call_new(test2_proxy, "ReceiveArrayOfStringIntWithSize");
iter = edbus_message_iter_get(msg);
@ -226,7 +225,6 @@ main(void)
}
edbus_message_iter_container_close(iter, array_of_string);
pending = edbus_proxy_send(test2_proxy, msg, on_receive_array_with_size, NULL, -1);
edbus_message_unref(msg);
msg = edbus_proxy_method_call_new(test2_proxy, "SendVariantData");
iter = edbus_message_iter_get(msg);
@ -234,7 +232,6 @@ main(void)
edbus_message_iter_basic_append(variant, 's', "test");
edbus_message_iter_container_close(iter, variant);
pending = edbus_proxy_send(test2_proxy, msg, on_send_variant, NULL, -1);
edbus_message_unref(msg);
msg = edbus_proxy_method_call_new(test2_proxy, "DoubleContainner");
iter = edbus_message_iter_get(msg);
@ -260,7 +257,6 @@ main(void)
}
edbus_message_iter_container_close(iter, array_itr);
edbus_proxy_send(test2_proxy, msg, NULL, NULL, -1);
edbus_message_unref(msg);
pending = edbus_proxy_call(test2_proxy, "SendArrayInt", on_send_array_int, NULL,
-1 , "");

View File

@ -130,7 +130,6 @@ _resp_async(void *data)
EDBus_Message *msg = data;
edbus_message_arguments_append(msg, "s", "Async test ok");
edbus_connection_send(conn, msg, NULL, NULL, -1);
edbus_message_unref(msg);
return ECORE_CALLBACK_CANCEL;
}

View File

@ -78,6 +78,5 @@ edbus_object_managed_objects_get(EDBus_Object *obj, EDBus_Message_Cb cb, const v
msg = edbus_object_method_call_new(obj, EDBUS_FDO_INTERFACE_OBJECT_MANAGER,
"GetManagedObjects");
p = edbus_object_send(obj, msg, cb, data, -1);
edbus_message_unref(msg);
return p;
}

View File

@ -648,7 +648,6 @@ edbus_object_peer_ping(EDBus_Object *obj, EDBus_Message_Cb cb, const void *data)
EDBUS_OBJECT_CHECK_RETVAL(obj, NULL);
msg = edbus_object_method_call_new(obj, EDBUS_FDO_INTEFACE_PEER, "Ping");
p = edbus_object_send(obj, msg, cb, data, -1);
edbus_message_unref(msg);
return p;
}
@ -661,7 +660,6 @@ edbus_object_peer_machine_id_get(EDBus_Object *obj, EDBus_Message_Cb cb, const v
msg = edbus_object_method_call_new(obj, EDBUS_FDO_INTEFACE_PEER,
"GetMachineId");
p = edbus_object_send(obj, msg, cb, data, -1);
edbus_message_unref(msg);
return p;
}
@ -674,6 +672,5 @@ edbus_object_introspect(EDBus_Object *obj, EDBus_Message_Cb cb, const void *data
msg = edbus_object_method_call_new(obj, EDBUS_FDO_INTERFACE_INTROSPECTABLE,
"Introspect");
p = edbus_object_send(obj, msg, cb, data, -1);
edbus_message_unref(msg);
return p;
}

View File

@ -103,17 +103,22 @@ edbus_connection_send(EDBus_Connection *conn, EDBus_Message *msg, EDBus_Message_
return pending;
}
/*
* On success @param msg is unref'd or its ref is stolen by the returned
* EDBus_Pending.
*/
EDBus_Pending *
_edbus_connection_send(EDBus_Connection *conn, EDBus_Message *msg, EDBus_Message_Cb cb, const void *cb_data, double timeout)
{
EDBus_Pending *pending;
EDBus_Message *error_msg;
DBG("conn=%p, msg=%p, cb=%p, cb_data=%p, timeout=%f",
conn, msg, cb, cb_data, timeout);
conn, msg, cb, cb_data, timeout);
if (!cb)
{
dbus_connection_send(conn->dbus_conn, msg->dbus_msg, NULL);
edbus_message_unref(msg);
return NULL;
}
@ -127,7 +132,10 @@ _edbus_connection_send(EDBus_Connection *conn, EDBus_Message *msg, EDBus_Message
pending->interface = eina_stringshare_add(dbus_message_get_interface(msg->dbus_msg));
pending->method = eina_stringshare_add(dbus_message_get_member(msg->dbus_msg));
pending->path = eina_stringshare_add(dbus_message_get_path(msg->dbus_msg));
pending->msg_sent = edbus_message_ref(msg);
/* Steal the reference */
pending->msg_sent = msg;
EINA_MAGIC_SET(pending, EDBUS_PENDING_MAGIC);
if (!dbus_connection_send_with_reply(conn->dbus_conn,

View File

@ -539,7 +539,6 @@ edbus_proxy_method_call_new(EDBus_Proxy *proxy, const char *member)
static EDBus_Pending *
_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)
{
EDBus_Pending *pending;
EDBus_Message *msg = edbus_proxy_method_call_new(proxy, member);
EINA_SAFETY_ON_NULL_RETURN_VAL(msg, NULL);
@ -550,9 +549,7 @@ _edbus_proxy_vcall(EDBus_Proxy *proxy, const char *member, EDBus_Message_Cb cb,
return NULL;
}
pending = _edbus_proxy_send(proxy, msg, cb, cb_data, timeout);
edbus_message_unref(msg);
return pending;
return _edbus_proxy_send(proxy, msg, cb, cb_data, timeout);
}
EAPI EDBus_Pending *
@ -628,7 +625,6 @@ edbus_proxy_property_set(EDBus_Proxy *proxy, const char *name, const char *sig,
{
EDBus_Message *msg;
EDBus_Message_Iter *iter, *variant;
EDBus_Pending *pending;
EDBUS_PROXY_CHECK_RETVAL(proxy, NULL);
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,
}
edbus_message_iter_container_close(iter, variant);
pending = edbus_proxy_send(proxy->obj->properties, msg, cb, data, -1);
edbus_message_unref(msg);
return pending;
return edbus_proxy_send(proxy->obj->properties, msg, cb, data, -1);
}
EAPI EDBus_Pending *

View File

@ -729,11 +729,13 @@ _iface_changed_send(void *data)
ERR("msg == NULL");
continue;
}
main_iter = edbus_message_iter_get(msg);
edbus_message_iter_arguments_append(main_iter, "oa{sa{sv}}",
iface->obj->path, &array_iface);
iface->obj->path, &array_iface);
if (!_propmgr_iface_props_append(iface, array_iface))
goto error;
EINA_LIST_FOREACH_SAFE(parent->iface_added, l, l2, next_iface)
{
if (iface->obj->path != next_iface->obj->path)
@ -747,6 +749,7 @@ _iface_changed_send(void *data)
edbus_message_iter_container_close(main_iter, array_iface);
edbus_connection_send(parent->conn, msg, NULL, NULL, -1);
continue;
error:
ERR("Error appending InterfacesAdded to msg.");
edbus_message_unref(msg);
@ -770,7 +773,7 @@ error:
main_iter = edbus_message_iter_get(msg);
edbus_message_iter_arguments_append(main_iter, "oas", iface_data->obj_path,
&array_iface);
&array_iface);
edbus_message_iter_basic_append(array_iface, 's', iface_data->iface);
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
if (!reply) return DBUS_HANDLER_RESULT_HANDLED;
_edbus_connection_send(obj->conn, reply, NULL, NULL, -1);
edbus_message_unref(reply);
return DBUS_HANDLER_RESULT_HANDLED;
}
@ -1259,7 +1261,6 @@ edbus_service_signal_send(const EDBus_Service_Interface *iface, EDBus_Message *s
EDBUS_SERVICE_INTERFACE_CHECK_RETVAL(iface, EINA_FALSE);
EINA_SAFETY_ON_NULL_RETURN_VAL(signal_msg, EINA_FALSE);
_edbus_connection_send(iface->obj->conn, signal_msg, NULL, NULL, -1);
edbus_message_unref(signal_msg);
return EINA_TRUE;
}

View File

@ -878,7 +878,6 @@ efreet_cache_desktop_add(Efreet_Desktop *desktop)
edbus_message_iter_basic_append(array_of_string, 's', path);
edbus_message_iter_container_close(iter, array_of_string);
edbus_proxy_send(proxy, msg, NULL, NULL, -1);
edbus_message_unref(msg);
free(path);
}
@ -898,7 +897,6 @@ efreet_cache_icon_exts_add(Eina_List *exts)
edbus_message_iter_basic_append(array_of_string, 's', ext);
edbus_message_iter_container_close(iter, array_of_string);
edbus_proxy_send(proxy, msg, NULL, NULL, -1);
edbus_message_unref(msg);
}
void
@ -917,7 +915,6 @@ efreet_cache_icon_dirs_add(Eina_List *dirs)
edbus_message_iter_basic_append(array_of_string, 's', dir);
edbus_message_iter_container_close(iter, array_of_string);
edbus_proxy_send(proxy, msg, NULL, NULL, -1);
edbus_message_unref(msg);
}
void

View File

@ -353,7 +353,6 @@ _ethumb_client_call_new(Ethumb_Client *client)
_ethumb_dbus_path,
_ethumb_dbus_interface, "new");
edbus_connection_send(client->conn, msg, _ethumb_client_new_cb, client, -1);
edbus_message_unref(msg);
}
static void
@ -822,7 +821,6 @@ ethumb_client_ethumb_setup(Ethumb_Client *client)
edbus_proxy_send(client->proxy, msg, _ethumb_client_ethumb_setup_cb,
client, -1);
edbus_message_unref(msg);
}
/**
@ -962,7 +960,6 @@ _ethumb_client_queue_add(Ethumb_Client *client, const char *file, const char *ke
_ethumb_client_queue_add_cb,
pending, -1);
client->pending_add = eina_list_append(client->pending_add, pending);
edbus_message_unref(msg);
return pending->id;
}