devilhorns pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=8b193c145ec0d9ecc9e9a16dbec335c9f209c0a3

commit 8b193c145ec0d9ecc9e9a16dbec335c9f209c0a3
Author: José Roberto de Souza <zehortig...@gmail.com>
Date:   Fri Dec 5 01:01:37 2014 -0200

    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.mich...@samsung.com>
---
 src/lib/eldbus/eldbus_pending.c | 29 ++++++++++++++++++-----------
 src/lib/eldbus/eldbus_proxy.h   |  8 +++-----
 2 files changed, 21 insertions(+), 16 deletions(-)

diff --git a/src/lib/eldbus/eldbus_pending.c b/src/lib/eldbus/eldbus_pending.c
index 87049c5..67c478d 100644
--- a/src/lib/eldbus/eldbus_pending.c
+++ b/src/lib/eldbus/eldbus_pending.c
@@ -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);
-   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_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);
 
-   dbus_message_iter_init_append(reply->dbus_msg, 
-                                 &reply->iterator->dbus_iterator);
+   reply = eldbus_message_new(EINA_FALSE);
+   EINA_SAFETY_ON_NULL_GOTO(reply, fail);
 
+   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
diff --git a/src/lib/eldbus/eldbus_proxy.h b/src/lib/eldbus/eldbus_proxy.h
index 3552378..69f5806 100644
--- a/src/lib/eldbus/eldbus_proxy.h
+++ b/src/lib/eldbus/eldbus_proxy.h
@@ -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);

-- 


Reply via email to