Merge lp:~agateau/libindicate/free-fixes into lp:libindicate/0.6

Proposed by Aurélien Gâteau
Status: Merged
Merged at revision: not available
Proposed branch: lp:~agateau/libindicate/free-fixes
Merge into: lp:libindicate/0.6
Diff against target: 51 lines (+9/-0)
2 files modified
libindicate/listener.c (+7/-0)
libindicate/server.c (+2/-0)
To merge this branch: bzr merge lp:~agateau/libindicate/free-fixes
Reviewer Review Type Date Requested Status
Ted Gould (community) Approve
Review via email: mp+18996@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Aurélien Gâteau (agateau) wrote :

Necessary to get more libindicate-qt tests to pass.

Revision history for this message
Ted Gould (ted) wrote :

  review needs-information

The remove filter makes complete sense to me.

The return on the destruction of the proxy struct doesn't. It seems
like if the proxy is already freed, we'd still need to clean up the
members of the proxy_t object itself. It seems like that'd just
introduce a memory leak as if the proxy dies we'd never destroy the
struct.

review: Needs Information
Revision history for this message
Aurélien Gâteau (agateau) wrote :

> review needs-information
>
> The remove filter makes complete sense to me.
>
> The return on the destruction of the proxy struct doesn't. It seems
> like if the proxy is already freed, we'd still need to clean up the
> members of the proxy_t object itself. It seems like that'd just
> introduce a memory leak as if the proxy dies we'd never destroy the
> struct.

I assumed this line from proxy_destroyed():

 proxyt->proxy = NULL; /* Clear this so we don't get a double free on this guy */

was setting proxy to NULL as a marker to avoid a crash in proxy_struct_destroy(), but now that I think more about it, I am probably wrong. My first attempt was to modify proxy_destroyed() so that it would remove the proxy_t instance from the listener proxies list. It failed, but it made more sense I think.

lp:~agateau/libindicate/free-fixes updated
363. By Aurélien Gâteau

More dbus filter fixes

364. By Aurélien Gâteau

Better fix for crash in double free on proxyt

Revision history for this message
Ted Gould (ted) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libindicate/listener.c'
2--- libindicate/listener.c 2010-02-09 03:10:00 +0000
3+++ libindicate/listener.c 2010-02-10 14:46:13 +0000
4@@ -110,6 +110,7 @@
5 static void proxy_indicator_modified (DBusGProxy * proxy, guint id, const gchar * property, proxy_t * proxyt);
6 static void proxy_server_count_changed (DBusGProxy * proxy, guint count, proxy_t * proxyt);
7 static void proxy_get_indicator_list (DBusGProxy * proxy, GArray * indicators, GError * error, gpointer data);
8+static void proxy_destroyed (GObject * proxy, gpointer user_data);
9
10 /* DBus interface */
11 gboolean _indicate_listener_server_get_indicator_servers (IndicateListener * listener, GList * servers);
12@@ -246,6 +247,8 @@
13 g_list_foreach(priv->proxies, (GFunc)proxy_struct_destroy, NULL);
14 g_list_free(priv->proxies);
15
16+ dbus_connection_remove_filter(dbus_g_connection_get_connection(priv->session_bus), dbus_filter_show_server, listener);
17+
18 G_OBJECT_CLASS (indicate_listener_parent_class)->finalize (obj);
19 return;
20 }
21@@ -349,6 +352,7 @@
22 }
23
24 if (DBUS_IS_G_PROXY(proxy_data->proxy)) {
25+ g_signal_handlers_disconnect_by_func(proxy_data->proxy, proxy_destroyed, proxy_data);
26 g_object_unref(G_OBJECT(proxy_data->proxy));
27 }
28
29@@ -402,6 +406,9 @@
30 {
31 proxy_t * proxyt = (proxy_t *)user_data;
32 proxyt->proxy = NULL; /* Clear this so we don't get a double free on this guy */
33+ IndicateListener * listener = proxyt->listener;
34+ IndicateListenerPrivate * priv = INDICATE_LISTENER_GET_PRIVATE(listener);
35+ priv->proxies = g_list_remove_all(priv->proxies, proxyt);
36 proxy_struct_destroy(proxyt);
37 return;
38 }
39
40=== modified file 'libindicate/server.c'
41--- libindicate/server.c 2010-02-05 22:53:21 +0000
42+++ libindicate/server.c 2010-02-10 14:46:13 +0000
43@@ -453,6 +453,8 @@
44 g_free(priv->type);
45 }
46
47+ dbus_connection_remove_filter(dbus_g_connection_get_connection(priv->connection), dbus_filter_new_listener, server);
48+
49 G_OBJECT_CLASS (indicate_server_parent_class)->finalize (obj);
50
51 return;

Subscribers

People subscribed via source and target branches