Merge lp:~ted/ubuntu-app-launch/lp1495871-unref-context into lp:ubuntu-app-launch/15.10

Proposed by Ted Gould
Status: Superseded
Proposed branch: lp:~ted/ubuntu-app-launch/lp1495871-unref-context
Merge into: lp:ubuntu-app-launch/15.10
Prerequisite: lp:~ted/ubuntu-app-launch/pids-tools
Diff against target: 57 lines (+12/-3)
2 files modified
helpers-shared.c (+11/-2)
libubuntu-app-launch/ubuntu-app-launch.h (+1/-1)
To merge this branch: bzr merge lp:~ted/ubuntu-app-launch/lp1495871-unref-context
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Indicator Applet Developers Pending
Review via email: mp+271322@code.launchpad.net

This proposal supersedes a proposal from 2015-09-16.

This proposal has been superseded by a proposal from 2015-12-02.

Commit message

Ensure all pending events on the context are complete before unref'ing it.

Description of the change

So while we create a context to ensure that we can capture all the events to the CGManager connection it seems that some of those events can get stuck on the context, and they need to get processed to complete. Otherwise they hold onto references of things, and that actually results in a g_spawn getting left around because it never gets free'd. (actually of the context itself, which is a bit confusing, but eh, refcounting is fun)

Also brought in the pid tools branch because it made testing this much, much easier. You can use the ubuntu-app-list-pids tool to cause the FD to be leaked and then see it fixed with something like (assuming you've done ubuntu-app-launch firefox):

valgrind --track-fds=yes ./ubuntu-app-list-pids firefox

Which on trunk will have 6 FDs left over, but with this branch only 5. (which come from globals that we don't control)

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
215. By Ted Gould

Merge FTBFS

Unmerged revisions

215. By Ted Gould

Merge FTBFS

214. By Ted Gould

Fix GDocs syntax for warning

213. By Ted Gould

Make sure get and set use the same value

212. By Ted Gould

Ensure that we process all the events on the context before unref'ing it. There may be references in the events.

211. By Ted Gould

Grabbing the pid tools branch

210. By Ted Gould

Easier to read an a cast that is needed

209. By Ted Gould

Plug leaking context

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'helpers-shared.c'
2--- helpers-shared.c 2015-07-15 02:32:54 +0000
3+++ helpers-shared.c 2015-09-16 14:36:19 +0000
4@@ -145,6 +145,8 @@
5 cgroup_manager_connection_core_cb(g_dbus_connection_new_for_address_finish, res, (cgm_connection_t *)data);
6 }
7
8+G_DEFINE_QUARK(CGMANAGER_CONTEXT, cgmanager_context);
9+
10 /* Get the connection to the cgroup manager */
11 GDBusConnection *
12 cgroup_manager_connection (void)
13@@ -191,7 +193,9 @@
14 g_main_context_pop_thread_default(context);
15
16 if (!use_session_bus && connection.con != NULL) {
17- g_object_set_data(G_OBJECT(connection.con), "cgmanager-context", context);
18+ g_object_set_qdata(G_OBJECT(connection.con),
19+ cgmanager_context_quark(),
20+ context);
21 } else {
22 g_main_context_unref(context);
23 }
24@@ -213,7 +217,7 @@
25 if (cgmanager == NULL)
26 return;
27
28- GMainContext * creationcontext = g_object_get_data(G_OBJECT(cgmanager), "cgmanager-context");
29+ GMainContext * creationcontext = g_object_get_qdata(G_OBJECT(cgmanager), cgmanager_context_quark());
30 if (creationcontext == NULL) {
31 g_object_unref(cgmanager);
32 return;
33@@ -228,6 +232,11 @@
34 }
35
36 g_object_unref(cgmanager);
37+
38+ while (g_main_context_pending(creationcontext)) {
39+ g_main_context_iteration(creationcontext, TRUE /* may block */);
40+ }
41+
42 g_main_context_unref(creationcontext);
43 }
44
45
46=== modified file 'libubuntu-app-launch/ubuntu-app-launch.h'
47--- libubuntu-app-launch/ubuntu-app-launch.h 2015-09-16 14:36:19 +0000
48+++ libubuntu-app-launch/ubuntu-app-launch.h 2015-09-16 14:36:19 +0000
49@@ -394,7 +394,7 @@
50 * Checks to see if an application is running and returns
51 * the PIDs associated with it.
52 *
53- * Return Value: (transfer full) (element-type GLib.Pid) A list
54+ * Return Value: (transfer full) (element-type GLib.Pid): A list
55 * of PIDs associated with @appid, empty if not running.
56 */
57 GList * ubuntu_app_launch_get_pids (const gchar * appid);

Subscribers

People subscribed via source and target branches