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

Proposed by Stephen M. Webb
Status: Merged
Approved by: Christopher Townsend
Approved revision: no longer in the source branch.
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 Approve
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.
Revision history for this message
Christopher Townsend (townsend) wrote :

Ok

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/control'
--- debian/control 2014-06-23 15:29:36 +0000
+++ debian/control 2015-03-11 18:15:10 +0000
@@ -31,8 +31,6 @@
31 libindicator3-dev (>= 0.12.2),31 libindicator3-dev (>= 0.12.2),
32 libjson-glib-dev,32 libjson-glib-dev,
33 libjson-perl,33 libjson-perl,
34 libnih-dbus-dev,
35 libnih-dev,
36 libnotify-dev,34 libnotify-dev,
37 libnux-4.0-dev (>= 4.0.6),35 libnux-4.0-dev (>= 4.0.6),
38 libpam0g-dev,36 libpam0g-dev,
@@ -109,8 +107,7 @@
109Package: unity-services107Package: unity-services
110Architecture: any108Architecture: any
111Depends: ${shlibs:Depends},109Depends: ${shlibs:Depends},
112 ${misc:Depends},110 ${misc:Depends}
113 upstart,
114Description: Services for the Unity interface111Description: Services for the Unity interface
115 Unity is a desktop experience that sings. Designed by Canonical and the Ayatana112 Unity is a desktop experience that sings. Designed by Canonical and the Ayatana
116 community, Unity is all about the combination of familiarity and the future. We113 community, Unity is all about the combination of familiarity and the future. We
117114
=== modified file 'services/CMakeLists.txt'
--- services/CMakeLists.txt 2014-01-08 15:05:53 +0000
+++ services/CMakeLists.txt 2015-03-11 18:15:10 +0000
@@ -13,9 +13,6 @@
13 x1113 x11
14 libido3-0.1>=13.0.014 libido3-0.1>=13.0.0
15 libupstart15 libupstart
16 libnih
17 libnih-dbus
18 dbus-1
19)16)
2017
21pkg_check_modules(SERVICE_DEPS REQUIRED ${UNITY_PANEL_SERVICE_DEPS})18pkg_check_modules(SERVICE_DEPS REQUIRED ${UNITY_PANEL_SERVICE_DEPS})
2219
=== modified file 'services/panel-service.c'
--- services/panel-service.c 2014-12-09 15:41:53 +0000
+++ services/panel-service.c 2015-03-11 18:15:10 +0000
@@ -33,9 +33,7 @@
33#include <X11/XKBlib.h>33#include <X11/XKBlib.h>
34#include <X11/extensions/XInput2.h>34#include <X11/extensions/XInput2.h>
3535
36#include <upstart.h>36#include <upstart/upstart-dbus.h>
37#include <nih/alloc.h>
38#include <nih/error.h>
3937
40G_DEFINE_TYPE (PanelService, panel_service, G_TYPE_OBJECT);38G_DEFINE_TYPE (PanelService, panel_service, G_TYPE_OBJECT);
4139
@@ -86,8 +84,6 @@
8684
87 IndicatorObjectEntry *pressed_entry;85 IndicatorObjectEntry *pressed_entry;
88 gboolean use_event;86 gboolean use_event;
89
90 NihDBusProxy * upstart;
91};87};
9288
93/* Globals */89/* Globals */
@@ -138,6 +134,7 @@
138static void sort_indicators (PanelService *);134static void sort_indicators (PanelService *);
139static void notify_object (IndicatorObject *object);135static void notify_object (IndicatorObject *object);
140static void update_keybinding (GSettings *, const gchar *, gpointer);136static void update_keybinding (GSettings *, const gchar *, gpointer);
137static void emit_upstart_event (const gchar *);
141static GdkFilterReturn event_filter (GdkXEvent *, GdkEvent *, PanelService *);138static GdkFilterReturn event_filter (GdkXEvent *, GdkEvent *, PanelService *);
142139
143/*140/*
@@ -153,21 +150,8 @@
153 g_idle_remove_by_data (self);150 g_idle_remove_by_data (self);
154 gdk_window_remove_filter (NULL, (GdkFilterFunc)event_filter, self);151 gdk_window_remove_filter (NULL, (GdkFilterFunc)event_filter, self);
155152
156 if (priv->upstart != NULL && !lockscreen_mode)153 if (!lockscreen_mode)
157 {154 emit_upstart_event ("indicator-services-end");
158 int event_sent = 0;
159 event_sent = upstart_emit_event_sync (NULL, priv->upstart,
160 "indicator-services-end", NULL, 0);
161 if (event_sent != 0)
162 {
163 NihError * err = nih_error_get();
164 g_warning("Unable to signal for indicator services to stop: %s", err->message);
165 nih_free(err);
166 }
167
168 nih_unref (priv->upstart, NULL);
169 priv->upstart = NULL;
170 }
171155
172 if (GTK_IS_WIDGET (priv->last_menu) &&156 if (GTK_IS_WIDGET (priv->last_menu) &&
173 gtk_widget_get_realized (GTK_WIDGET (priv->last_menu)))157 gtk_widget_get_realized (GTK_WIDGET (priv->last_menu)))
@@ -623,17 +607,8 @@
623static gboolean607static gboolean
624ready_signal (PanelService *self)608ready_signal (PanelService *self)
625{609{
626 if (PANEL_IS_SERVICE (self) && self->priv->upstart != NULL && !lockscreen_mode)610 if (!lockscreen_mode)
627 {611 emit_upstart_event ("indicator-services-start");
628 int event_sent = 0;
629 event_sent = upstart_emit_event_sync (NULL, self->priv->upstart, "indicator-services-start", NULL, 0);
630 if (event_sent != 0)
631 {
632 NihError * err = nih_error_get();
633 g_warning("Unable to signal for indicator services to start: %s", err->message);
634 nih_free(err);
635 }
636 }
637612
638 return FALSE;613 return FALSE;
639}614}
@@ -726,6 +701,48 @@
726}701}
727702
728static void703static void
704emit_upstart_event (const gchar *event)
705{
706 const gchar *upstartsession = g_getenv ("UPSTART_SESSION");
707
708 if (!upstartsession)
709 return;
710
711 GError *error = NULL;
712 GDBusConnection* conn = g_dbus_connection_new_for_address_sync (upstartsession,
713 G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT,
714 NULL, NULL, &error);
715
716 if (error)
717 {
718 g_warning ("Unable to connect to Upstart session: %s", error->message);
719 g_error_free (error);
720 return;
721 }
722
723 GVariant *result = g_dbus_connection_call_sync (conn, DBUS_SERVICE_UPSTART,
724 DBUS_PATH_UPSTART,
725 DBUS_INTERFACE_UPSTART,
726 "EmitEvent",
727 g_variant_new ("(sasb)", event, NULL, 0),
728 NULL, G_DBUS_CALL_FLAGS_NO_AUTO_START, -1,
729 NULL, &error);
730
731 if (error)
732 {
733 g_warning ("Unable to emit Upstart event: %s", error->message);
734 g_error_free (error);
735 }
736 else
737 {
738 g_variant_unref (result);
739 }
740
741 g_object_unref (conn);
742}
743
744
745static void
729panel_service_init (PanelService *self)746panel_service_init (PanelService *self)
730{747{
731 PanelServicePrivate *priv;748 PanelServicePrivate *priv;
@@ -749,29 +766,6 @@
749 update_keybinding (priv->gsettings, MENU_TOGGLE_KEYBINDING_KEY, &priv->menu_toggle);766 update_keybinding (priv->gsettings, MENU_TOGGLE_KEYBINDING_KEY, &priv->menu_toggle);
750 update_keybinding (priv->gsettings, SHOW_DASH_KEY, &priv->show_dash);767 update_keybinding (priv->gsettings, SHOW_DASH_KEY, &priv->show_dash);
751 update_keybinding (priv->gsettings, SHOW_HUD_KEY, &priv->show_hud);768 update_keybinding (priv->gsettings, SHOW_HUD_KEY, &priv->show_hud);
752
753 const gchar *upstartsession = g_getenv ("UPSTART_SESSION");
754 if (upstartsession != NULL && !lockscreen_mode)
755 {
756 DBusConnection *conn = dbus_connection_open (upstartsession, NULL);
757 if (conn != NULL)
758 {
759 priv->upstart = nih_dbus_proxy_new (NULL, conn,
760 NULL,
761 DBUS_PATH_UPSTART,
762 NULL, NULL);
763 if (priv->upstart == NULL)
764 {
765 NihError * err = nih_error_get();
766 g_warning("Unable to get Upstart proxy: %s", err->message);
767 nih_free(err);
768 }
769 dbus_connection_unref (conn);
770 }
771 }
772
773 if (priv->upstart != NULL)
774 priv->upstart->auto_start = FALSE;
775}769}
776770
777static gboolean771static gboolean
778772
=== modified file 'tests/CMakeLists.txt'
--- tests/CMakeLists.txt 2014-12-08 19:51:05 +0000
+++ tests/CMakeLists.txt 2015-03-11 18:15:10 +0000
@@ -8,7 +8,7 @@
8#8#
9# Unit tests9# Unit tests
10#10#
11set (TEST_DEPS "${UNITY_PLUGIN_DEPS};unity>=4.99.0;libupstart;libnih;libnih-dbus;dbus-1")11set (TEST_DEPS "${UNITY_PLUGIN_DEPS};unity>=4.99.0;libupstart;")
12pkg_check_modules (TEST_UNIT_DEPS REQUIRED ${TEST_DEPS})12pkg_check_modules (TEST_UNIT_DEPS REQUIRED ${TEST_DEPS})
1313
14string (REPLACE ";" " " TEST_UNIT_DEPS_CFLAGS_OTHER "${TEST_UNIT_CFLAGS_OTHER}")14string (REPLACE ";" " " TEST_UNIT_DEPS_CFLAGS_OTHER "${TEST_UNIT_CFLAGS_OTHER}")
1515
=== modified file 'unity-shared/UpstartWrapper.cpp'
--- unity-shared/UpstartWrapper.cpp 2014-03-04 14:10:26 +0000
+++ unity-shared/UpstartWrapper.cpp 2015-03-11 18:15:10 +0000
@@ -20,6 +20,7 @@
20#include "UpstartWrapper.h"20#include "UpstartWrapper.h"
2121
22#include <UnityCore/GLibDBusProxy.h>22#include <UnityCore/GLibDBusProxy.h>
23#include <upstart/upstart-dbus.h>
2324
24namespace unity25namespace unity
25{26{
@@ -41,9 +42,8 @@
4142
42UpstartWrapper::Impl::Impl(bool test_mode)43UpstartWrapper::Impl::Impl(bool test_mode)
43{44{
44 upstart_proxy_ = std::make_shared<unity::glib::DBusProxy>(test_mode ? "com.canonical.Unity.Test.Upstart" : "com.ubuntu.Upstart",45 upstart_proxy_ = std::make_shared<unity::glib::DBusProxy>(test_mode ? "com.canonical.Unity.Test.Upstart" : DBUS_SERVICE_UPSTART,
45 "/com/ubuntu/Upstart", 46 DBUS_PATH_UPSTART, DBUS_INTERFACE_UPSTART);
46 "com.ubuntu.Upstart0_6");
47}47}
4848
49void UpstartWrapper::Impl::Emit(std::string const& name)49void UpstartWrapper::Impl::Emit(std::string const& name)

Subscribers

People subscribed via source and target branches

to all changes:
to status/vote changes: