Hi,

On 9/17/07, Ulisses Furquim <[EMAIL PROTECTED]> wrote:
> This patch also uses dbus_connection_ref (and later
> dbus_connection_unref) for storing a pointer to the DBusConnection
> structure and dbus_message_ref / dbus_message_unref to manage a
> reference to the D-Bus message.

Gustavo applied this patch but it wasn't as good as it seemed, sorry about that.

We don't need the dbus_connection_ref and _unref because we already
own a reference to the connection after calling dbus_bus_get_private
inside e_dbus_bus_get. Moreover, we're storing a pointer to our
E_DBus_Connection variable in the DBusConnection and setting a
function to free it when the data is replaced or the connection is
finalized (see e_dbus_connection_setup). However, the dbus connection
will never be finalized because we're holding one reference to it
inside our E_DBus_Connection strucuture! This extra reference we're
holding is preventing e_dbus_connection_close from finalizing the dbus
connection (see the Note in the code there). Thus, we're leaking both
the dbus connection and our E_DBus_Connection. Not good, not good at
all. :-/

The attached patch solves the problem (applies to current CVS).

Best regards,

-- Ulisses
Index: proto/e_dbus/src/lib/dbus/e_dbus.c
===================================================================
RCS file: /var/cvs/e/e17/proto/e_dbus/src/lib/dbus/e_dbus.c,v
retrieving revision 1.8
diff -u -r1.8 e_dbus.c
--- proto/e_dbus/src/lib/dbus/e_dbus.c	26 Sep 2007 14:08:44 -0000	1.8
+++ proto/e_dbus/src/lib/dbus/e_dbus.c	26 Sep 2007 18:30:46 -0000
@@ -146,7 +146,7 @@
   cd = calloc(1, sizeof(E_DBus_Connection));
   if (!cd) return NULL;
 
-  cd->conn = dbus_connection_ref(conn);
+  cd->conn = conn;
   cd->conn_name = strdup(dbus_bus_get_unique_name(conn));
 
   DEBUG(1, "Connected! Name: %s\n", cd->conn_name);
@@ -180,7 +180,6 @@
     shared_connections[cd->shared_type] = NULL;
 
   if (cd->conn_name) free(cd->conn_name);
-  dbus_connection_unref(cd->conn);
 
   free(cd);
 }
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to