Merge lp:~afrantzis/powerd/fix-1531158 into lp:powerd

Proposed by Alexandros Frantzis
Status: Merged
Approved by: Alexandros Frantzis
Approved revision: 181
Merged at revision: 181
Proposed branch: lp:~afrantzis/powerd/fix-1531158
Merge into: lp:powerd
Diff against target: 110 lines (+40/-22)
2 files modified
debian/changelog (+8/-0)
src/display.c (+32/-22)
To merge this branch: bzr merge lp:~afrantzis/powerd/fix-1531158
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Ubuntu Phablet Team Pending
Review via email: mp+282169@code.launchpad.net

Commit message

Keep the dbus proxy to Unity.Screen (implemented by USC) alive for
the lifetime of the process. Otherwise we may block when trying to
create the proxy while servicing a request from USC (LP: #1531158)

Description of the change

Keep the dbus proxy to Unity.Screen (implemented by USC) alive for
the lifetime of the process. Otherwise we may block when trying to
create the proxy while servicing a request from USC (LP: #1531158)

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2015-09-30 12:29:39 +0000
+++ debian/changelog 2016-01-11 13:36:27 +0000
@@ -1,3 +1,11 @@
1powerd (0.16+16.04.20160111-0ubuntu1) xenial; urgency=medium
2
3 * Keep the dbus proxy to Unity.Screen (implemented by USC) alive for
4 the lifetime of the process. Otherwise we may block when trying to
5 create the proxy while servicing a request from USC (LP: #1531158)
6
7 -- Alexandros Frantzis <alexandros.frantzis@canonical.com> Mon, 11 Jan 2016 13:12:11 +0000
8
1powerd (0.16+15.10.20150930-0ubuntu1) wily; urgency=medium9powerd (0.16+15.10.20150930-0ubuntu1) wily; urgency=medium
210
3 [ Alexandros Frantzis ]11 [ Alexandros Frantzis ]
412
=== modified file 'src/display.c'
--- src/display.c 2014-06-18 18:06:10 +0000
+++ src/display.c 2016-01-11 13:36:27 +0000
@@ -29,26 +29,39 @@
29#include "powerd-internal.h"29#include "powerd-internal.h"
30#include "log.h"30#include "log.h"
3131
32static GDBusProxy* create_uscreen_proxy()32static GDBusProxy* uscreen_proxy_get()
33{33{
34 GError *error = NULL;34 static GMutex mutex;
35 GDBusProxy *uscreen_proxy = NULL;35 static GDBusProxy *uscreen_proxy = NULL;
36 uscreen_proxy = g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM,36 GDBusProxy *uscreen_proxy_tmp = NULL;
37 G_DBUS_PROXY_FLAGS_NONE,37
38 NULL,38 g_mutex_lock(&mutex);
39 "com.canonical.Unity.Screen",39
40 "/com/canonical/Unity/Screen",40 if (uscreen_proxy == NULL)
41 "com.canonical.Unity.Screen",41 {
42 NULL,42 GError *error = NULL;
43 &error);43
4444 uscreen_proxy = g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM,
45 if (error != NULL) {45 G_DBUS_PROXY_FLAGS_NONE,
46 powerd_warn("could not connect to Unity.Screen: %s", error->message);46 NULL,
47 g_error_free(error);47 "com.canonical.Unity.Screen",
48 return NULL;48 "/com/canonical/Unity/Screen",
49 "com.canonical.Unity.Screen",
50 NULL,
51 &error);
52
53 if (error != NULL) {
54 powerd_warn("could not connect to Unity.Screen: %s", error->message);
55 g_error_free(error);
56 uscreen_proxy = NULL;
57 }
49 }58 }
5059
51 return uscreen_proxy;60 uscreen_proxy_tmp = uscreen_proxy;
61
62 g_mutex_unlock(&mutex);
63
64 return uscreen_proxy_tmp;
52}65}
5366
54static void request_keep_display_on(GDBusConnection *connection,67static void request_keep_display_on(GDBusConnection *connection,
@@ -63,7 +76,7 @@
6376
64 powerd_debug("request_keep_display_on");77 powerd_debug("request_keep_display_on");
6578
66 uscreen_proxy = create_uscreen_proxy();79 uscreen_proxy = uscreen_proxy_get();
67 if (uscreen_proxy == NULL)80 if (uscreen_proxy == NULL)
68 {81 {
69 powerd_warn("failed creating unity screen proxy to keep display on");82 powerd_warn("failed creating unity screen proxy to keep display on");
@@ -88,7 +101,6 @@
88 powerd_debug("keepDisplayOn request succeeded - id: %d", request_id);101 powerd_debug("keepDisplayOn request succeeded - id: %d", request_id);
89102
90 g_variant_unref(ret);103 g_variant_unref(ret);
91 g_object_unref(uscreen_proxy);
92}104}
93105
94gboolean turn_display_on(gboolean on, enum DisplayStateChangeReason reason)106gboolean turn_display_on(gboolean on, enum DisplayStateChangeReason reason)
@@ -100,7 +112,7 @@
100 if (on)112 if (on)
101 powerd_hal_signal_activity();113 powerd_hal_signal_activity();
102114
103 uscreen_proxy = create_uscreen_proxy();115 uscreen_proxy = uscreen_proxy_get();
104 if (uscreen_proxy == NULL)116 if (uscreen_proxy == NULL)
105 return FALSE;117 return FALSE;
106118
@@ -113,8 +125,6 @@
113 NULL,125 NULL,
114 NULL);126 NULL);
115127
116 g_object_unref(uscreen_proxy);
117
118 return TRUE;128 return TRUE;
119}129}
120130

Subscribers

People subscribed via source and target branches