eldbus: Fix _eldbus_connection_send_and_block()
Some problems with the actual implementation: - the reply should not be writable, as it can only be read. - if an error happen dbus_connection_send_with_reply_and_block() will return NULL so we need check before use it - all other send calls remove one reference of the message Now also it is creating a error message, so the caller can know why it fail. @fix Signed-off-by: Chris Michael <cp.michael@samsung.com>
This commit is contained in:
parent
44f0f3e170
commit
8b193c145e
|
@ -161,26 +161,33 @@ _eldbus_connection_send(Eldbus_Connection *conn, Eldbus_Message *msg, Eldbus_Mes
|
|||
Eldbus_Message *
|
||||
_eldbus_connection_send_and_block(Eldbus_Connection *conn, Eldbus_Message *msg)
|
||||
{
|
||||
Eldbus_Message *reply;
|
||||
Eldbus_Message *reply = NULL;
|
||||
DBusError err;
|
||||
DBusMessage *dbus_msg;
|
||||
|
||||
if (ecore_main_loop_nested_get())
|
||||
WRN("Calling this function may result in dropped frames because the main loop is running");
|
||||
|
||||
reply = eldbus_message_new(EINA_TRUE);
|
||||
dbus_error_init(&err);
|
||||
dbus_msg = dbus_connection_send_with_reply_and_block(conn->dbus_conn,
|
||||
msg->dbus_msg, -1, &err);
|
||||
EINA_SAFETY_ON_TRUE_GOTO(dbus_error_is_set(&err), dbus_error_set);
|
||||
dbus_error_free(&err);
|
||||
|
||||
reply = eldbus_message_new(EINA_FALSE);
|
||||
EINA_SAFETY_ON_NULL_GOTO(reply, fail);
|
||||
|
||||
reply->dbus_msg =
|
||||
dbus_connection_send_with_reply_and_block(conn->dbus_conn,
|
||||
msg->dbus_msg, -1, NULL);
|
||||
|
||||
dbus_message_iter_init_append(reply->dbus_msg,
|
||||
&reply->iterator->dbus_iterator);
|
||||
|
||||
reply->dbus_msg = dbus_msg;
|
||||
dbus_message_iter_init(reply->dbus_msg, &reply->iterator->dbus_iterator);
|
||||
eldbus_message_unref(msg);
|
||||
return reply;
|
||||
|
||||
dbus_error_set:
|
||||
reply = eldbus_message_error_new(msg, err.name, err.message);
|
||||
dbus_error_free(&err);
|
||||
fail:
|
||||
eldbus_message_unref(reply);
|
||||
return NULL;
|
||||
eldbus_message_unref(msg);
|
||||
return reply;
|
||||
}
|
||||
|
||||
EAPI void
|
||||
|
|
|
@ -117,15 +117,13 @@ EAPI Eldbus_Message *eldbus_proxy_method_call_new(Eldbus_Proxy *proxy, co
|
|||
EAPI Eldbus_Pending *eldbus_proxy_send(Eldbus_Proxy *proxy, Eldbus_Message *msg, Eldbus_Message_Cb cb, const void *cb_data, double timeout) EINA_ARG_NONNULL(1, 2);
|
||||
|
||||
/**
|
||||
* @brief Send a message and block while waiting for the reply
|
||||
* @brief Send a message and block while waiting for the reply.
|
||||
*
|
||||
* @param proxy the msg will be send in connection that proxy belongs
|
||||
* @param msg message that will be send
|
||||
* @param cb if msg is a method call a callback should be passed
|
||||
* @param cb_data data passed to callback
|
||||
*
|
||||
* @return A Eldbus_Pending object on the sent message.
|
||||
*
|
||||
* @return The reply message, error message or NULL.
|
||||
* The returned Eldbus_Message need to be unref after read.
|
||||
* @since 1.13
|
||||
*/
|
||||
EAPI Eldbus_Message *eldbus_proxy_send_and_block(Eldbus_Proxy *proxy, Eldbus_Message *msg) EINA_ARG_NONNULL(1, 2);
|
||||
|
|
Loading…
Reference in New Issue