Merge lp:~phablet-team/powerd/power-block-reboot into lp:powerd

Proposed by Ricardo Mendoza
Status: Merged
Approved by: Ricardo Salveti
Approved revision: 165
Merged at revision: 163
Proposed branch: lp:~phablet-team/powerd/power-block-reboot
Merge into: lp:powerd
Diff against target: 83 lines (+42/-1)
2 files modified
src/powerd-object.c (+7/-1)
src/powerd.cpp (+35/-0)
To merge this branch: bzr merge lp:~phablet-team/powerd/power-block-reboot
Reviewer Review Type Date Requested Status
Ricardo Salveti (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+258557@code.launchpad.net

Commit message

Watch com.canonical.Unity.Screen vanishing from the bus (USC/Unity8 not running) to hold a lock until either we poweroff, or Unity returns. Also, add a delay for clearing requests from dead bus names (LP: #1452300)

To post a comment you must log in.
164. By Ricardo Mendoza

Remove debug

165. By Ricardo Mendoza

Wrong name

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Ricardo Salveti (rsalveti) wrote :

Looks good, works as expected. Thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/powerd-object.c'
2--- src/powerd-object.c 2015-04-30 17:18:58 +0000
3+++ src/powerd-object.c 2015-05-07 20:32:36 +0000
4@@ -406,13 +406,19 @@
5 *proxy = unity_proxy;
6 }
7
8+static gboolean delayed_clear_request(gpointer userdata)
9+{
10+ clear_sys_state_by_owner((gchar*) userdata);
11+ return FALSE;
12+}
13+
14 void
15 powerd_name_vanished_cb(GDBusConnection *connection,
16 const gchar *name,
17 gpointer user_data)
18 {
19 powerd_warn("%s vanished from dbus, clearing associated requests", name);
20- clear_sys_state_by_owner(name);
21+ g_timeout_add(5000, delayed_clear_request, (gpointer) name);
22 powerd_client_unregister(name);
23 // This can return false if the hash entry was removed because the
24 // last request was dropped, in other words, this call will fail
25
26=== modified file 'src/powerd.cpp'
27--- src/powerd.cpp 2014-10-24 23:52:09 +0000
28+++ src/powerd.cpp 2015-05-07 20:32:36 +0000
29@@ -60,6 +60,8 @@
30
31 static int call_added = 0;
32
33+static uuid_t screen_cookie;
34+
35 /* Used to track modem interfaces */
36 struct modem_data {
37 char *obj_name;
38@@ -331,6 +333,29 @@
39 }
40 }
41
42+void
43+unity_screen_name_appeared_cb(GDBusConnection *connection,
44+ const gchar *name,
45+ gpointer user_data)
46+{
47+ if (!uuid_is_null(screen_cookie)) {
48+ clear_sys_state_internal(screen_cookie);
49+ uuid_clear(screen_cookie);
50+ }
51+}
52+
53+void
54+unity_screen_name_vanished_cb(GDBusConnection *connection,
55+ const gchar *name,
56+ gpointer user_data)
57+{
58+ if (uuid_is_null(screen_cookie)) {
59+ request_sys_state_internal("shutdown-request",
60+ POWERD_SYS_STATE_ACTIVE,
61+ &screen_cookie, NULL);
62+ }
63+}
64+
65 /* Must be first to run on main loop */
66 static gboolean main_init(gpointer unused)
67 {
68@@ -409,6 +434,16 @@
69 (GAsyncReadyCallback) unity_proxy_connect_cb,
70 &g_unity_proxy);
71
72+ /* Initialize screen cookie before setting up listener */
73+ uuid_clear(screen_cookie);
74+
75+ /* Register for com.canonical.Unity.Screen name ownership changes */
76+ g_bus_watch_name(G_BUS_TYPE_SYSTEM, "com.canonical.Unity.Screen",
77+ G_BUS_NAME_WATCHER_FLAGS_NONE,
78+ (GBusNameAppearedCallback)unity_screen_name_appeared_cb,
79+ (GBusNameVanishedCallback)unity_screen_name_vanished_cb,
80+ NULL, NULL);
81+
82 /* Init this first, data is used by other inits */
83 device_config_init();
84

Subscribers

People subscribed via source and target branches

to all changes: