Merge lp:~3v1n0/unity/ups-nhi-remove into lp:unity

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Andrea Azzarone
Approved revision: no longer in the source branch.
Merged at revision: 3891
Proposed branch: lp:~3v1n0/unity/ups-nhi-remove
Merge into: lp:unity
Prerequisite: lp:~3v1n0/unity/ups-special-keys
Diff against target: 226 lines (+52/-64)
5 files modified
debian/control (+0/-3)
services/CMakeLists.txt (+0/-3)
services/panel-service.c (+48/-54)
tests/CMakeLists.txt (+1/-1)
unity-shared/UpstartWrapper.cpp (+3/-3)
To merge this branch: bzr merge lp:~3v1n0/unity/ups-nhi-remove
Reviewer Review Type Date Requested Status
Andrea Azzarone (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+240631@code.launchpad.net

Commit message

PanelService: use gdbus to notfy upstart of service start/stop

This fixes a memory leak caused by the nih dbus proxy

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

LGTM.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/control'
2--- debian/control 2014-09-03 07:35:09 +0000
3+++ debian/control 2014-11-04 19:05:20 +0000
4@@ -31,8 +31,6 @@
5 libindicator3-dev (>= 0.12.2),
6 libjson-glib-dev,
7 libjson-perl,
8- libnih-dbus-dev,
9- libnih-dev,
10 libnotify-dev,
11 libnux-4.0-dev (>= 4.0.6),
12 libpam0g-dev,
13@@ -110,7 +108,6 @@
14 Architecture: any
15 Depends: ${shlibs:Depends},
16 ${misc:Depends},
17- upstart-bin,
18 Description: Services for the Unity interface
19 Unity is a desktop experience that sings. Designed by Canonical and the Ayatana
20 community, Unity is all about the combination of familiarity and the future. We
21
22=== modified file 'services/CMakeLists.txt'
23--- services/CMakeLists.txt 2014-01-08 15:05:53 +0000
24+++ services/CMakeLists.txt 2014-11-04 19:05:20 +0000
25@@ -13,9 +13,6 @@
26 x11
27 libido3-0.1>=13.0.0
28 libupstart
29- libnih
30- libnih-dbus
31- dbus-1
32 )
33
34 pkg_check_modules(SERVICE_DEPS REQUIRED ${UNITY_PANEL_SERVICE_DEPS})
35
36=== modified file 'services/panel-service.c'
37--- services/panel-service.c 2014-11-04 19:05:20 +0000
38+++ services/panel-service.c 2014-11-04 19:05:20 +0000
39@@ -34,9 +34,7 @@
40 #include <X11/XF86keysym.h>
41 #include <X11/extensions/XInput2.h>
42
43-#include <upstart.h>
44-#include <nih/alloc.h>
45-#include <nih/error.h>
46+#include <upstart/upstart-dbus.h>
47
48 G_DEFINE_TYPE (PanelService, panel_service, G_TYPE_OBJECT);
49
50@@ -87,8 +85,6 @@
51
52 IndicatorObjectEntry *pressed_entry;
53 gboolean use_event;
54-
55- NihDBusProxy * upstart;
56 };
57
58 /* Globals */
59@@ -139,6 +135,7 @@
60 static void sort_indicators (PanelService *);
61 static void notify_object (IndicatorObject *object);
62 static void update_keybinding (GSettings *, const gchar *, gpointer);
63+static void emit_upstart_event (const gchar *);
64 static GdkFilterReturn event_filter (GdkXEvent *, GdkEvent *, PanelService *);
65
66 /*
67@@ -154,21 +151,8 @@
68 g_idle_remove_by_data (self);
69 gdk_window_remove_filter (NULL, (GdkFilterFunc)event_filter, self);
70
71- if (priv->upstart != NULL && !lockscreen_mode)
72- {
73- int event_sent = 0;
74- event_sent = upstart_emit_event_sync (NULL, priv->upstart,
75- "indicator-services-end", NULL, 0);
76- if (event_sent != 0)
77- {
78- NihError * err = nih_error_get();
79- g_warning("Unable to signal for indicator services to stop: %s", err->message);
80- nih_free(err);
81- }
82-
83- nih_unref (priv->upstart, NULL);
84- priv->upstart = NULL;
85- }
86+ if (!lockscreen_mode)
87+ emit_upstart_event ("indicator-services-end");
88
89 if (GTK_IS_WIDGET (priv->last_menu) &&
90 gtk_widget_get_realized (GTK_WIDGET (priv->last_menu)))
91@@ -685,17 +669,8 @@
92 static gboolean
93 ready_signal (PanelService *self)
94 {
95- if (PANEL_IS_SERVICE (self) && self->priv->upstart != NULL && !lockscreen_mode)
96- {
97- int event_sent = 0;
98- event_sent = upstart_emit_event_sync (NULL, self->priv->upstart, "indicator-services-start", NULL, 0);
99- if (event_sent != 0)
100- {
101- NihError * err = nih_error_get();
102- g_warning("Unable to signal for indicator services to start: %s", err->message);
103- nih_free(err);
104- }
105- }
106+ if (!lockscreen_mode)
107+ emit_upstart_event ("indicator-services-start");
108
109 return FALSE;
110 }
111@@ -788,6 +763,48 @@
112 }
113
114 static void
115+emit_upstart_event (const gchar *event)
116+{
117+ const gchar *upstartsession = g_getenv ("UPSTART_SESSION");
118+
119+ if (!upstartsession)
120+ return;
121+
122+ GError *error = NULL;
123+ GDBusConnection* conn = g_dbus_connection_new_for_address_sync (upstartsession,
124+ G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT,
125+ NULL, NULL, &error);
126+
127+ if (error)
128+ {
129+ g_warning ("Unable to connect to Upstart session: %s", error->message);
130+ g_error_free (error);
131+ return;
132+ }
133+
134+ GVariant *result = g_dbus_connection_call_sync (conn, DBUS_SERVICE_UPSTART,
135+ DBUS_PATH_UPSTART,
136+ DBUS_INTERFACE_UPSTART,
137+ "EmitEvent",
138+ g_variant_new ("(sasb)", event, NULL, 0),
139+ NULL, G_DBUS_CALL_FLAGS_NO_AUTO_START, -1,
140+ NULL, &error);
141+
142+ if (error)
143+ {
144+ g_warning ("Unable to emit Upstart event: %s", error->message);
145+ g_error_free (error);
146+ }
147+ else
148+ {
149+ g_variant_unref (result);
150+ }
151+
152+ g_object_unref (conn);
153+}
154+
155+
156+static void
157 panel_service_init (PanelService *self)
158 {
159 PanelServicePrivate *priv;
160@@ -811,29 +828,6 @@
161 update_keybinding (priv->gsettings, MENU_TOGGLE_KEYBINDING_KEY, &priv->menu_toggle);
162 update_keybinding (priv->gsettings, SHOW_DASH_KEY, &priv->show_dash);
163 update_keybinding (priv->gsettings, SHOW_HUD_KEY, &priv->show_hud);
164-
165- const gchar *upstartsession = g_getenv ("UPSTART_SESSION");
166- if (upstartsession != NULL && !lockscreen_mode)
167- {
168- DBusConnection *conn = dbus_connection_open (upstartsession, NULL);
169- if (conn != NULL)
170- {
171- priv->upstart = nih_dbus_proxy_new (NULL, conn,
172- NULL,
173- DBUS_PATH_UPSTART,
174- NULL, NULL);
175- if (priv->upstart == NULL)
176- {
177- NihError * err = nih_error_get();
178- g_warning("Unable to get Upstart proxy: %s", err->message);
179- nih_free(err);
180- }
181- dbus_connection_unref (conn);
182- }
183- }
184-
185- if (priv->upstart != NULL)
186- priv->upstart->auto_start = FALSE;
187 }
188
189 static gboolean
190
191=== modified file 'tests/CMakeLists.txt'
192--- tests/CMakeLists.txt 2014-10-14 22:37:37 +0000
193+++ tests/CMakeLists.txt 2014-11-04 19:05:20 +0000
194@@ -8,7 +8,7 @@
195 #
196 # Unit tests
197 #
198-set (TEST_DEPS "${UNITY_PLUGIN_DEPS};unity>=4.99.0;libupstart;libnih;libnih-dbus;dbus-1")
199+set (TEST_DEPS "${UNITY_PLUGIN_DEPS};unity>=4.99.0;libupstart;")
200 pkg_check_modules (TEST_UNIT_DEPS REQUIRED ${TEST_DEPS})
201
202 string (REPLACE ";" " " TEST_UNIT_DEPS_CFLAGS_OTHER "${TEST_UNIT_CFLAGS_OTHER}")
203
204=== modified file 'unity-shared/UpstartWrapper.cpp'
205--- unity-shared/UpstartWrapper.cpp 2014-03-04 14:10:26 +0000
206+++ unity-shared/UpstartWrapper.cpp 2014-11-04 19:05:20 +0000
207@@ -20,6 +20,7 @@
208 #include "UpstartWrapper.h"
209
210 #include <UnityCore/GLibDBusProxy.h>
211+#include <upstart/upstart-dbus.h>
212
213 namespace unity
214 {
215@@ -41,9 +42,8 @@
216
217 UpstartWrapper::Impl::Impl(bool test_mode)
218 {
219- upstart_proxy_ = std::make_shared<unity::glib::DBusProxy>(test_mode ? "com.canonical.Unity.Test.Upstart" : "com.ubuntu.Upstart",
220- "/com/ubuntu/Upstart",
221- "com.ubuntu.Upstart0_6");
222+ upstart_proxy_ = std::make_shared<unity::glib::DBusProxy>(test_mode ? "com.canonical.Unity.Test.Upstart" : DBUS_SERVICE_UPSTART,
223+ DBUS_PATH_UPSTART, DBUS_INTERFACE_UPSTART);
224 }
225
226 void UpstartWrapper::Impl::Emit(std::string const& name)