Merge lp:~bregma/unity/lp-1302955-trusty into lp:unity/7.2

Proposed by Stephen M. Webb on 2015-03-11
Status: Merged
Approved by: Christopher Townsend on 2015-03-12
Approved revision: 3808
Merged at revision: 3808
Proposed branch: lp:~bregma/unity/lp-1302955-trusty
Merge into: lp:unity/7.2
Diff against target: 228 lines (+53/-65)
5 files modified
debian/control (+1/-4)
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:~bregma/unity/lp-1302955-trusty
Reviewer Review Type Date Requested Status
Christopher Townsend 2015-03-11 Approve on 2015-03-12
Review via email: mp+252629@code.launchpad.net

Commit message

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

Description of the change

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

This fixes a memory leak caused by the nih dbus proxy.

Cherry-picked from Unity trunk.

To post a comment you must log in.
Christopher Townsend (townsend) wrote :

Ok

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

Subscribers

People subscribed via source and target branches

to all changes:
to status/vote changes: