Merge lp:~mfisch/powerd/lp1195800 into lp:powerd

Proposed by Matt Fischer
Status: Merged
Approved by: Seth Forshee
Approved revision: 65
Merged at revision: 63
Proposed branch: lp:~mfisch/powerd/lp1195800
Merge into: lp:powerd
Diff against target: 126 lines (+17/-35)
4 files modified
debian/upstart (+6/-25)
src/powerd-internal.h (+1/-1)
src/powerd-object.c (+4/-3)
src/powerd.cpp (+6/-6)
To merge this branch: bzr merge lp:~mfisch/powerd/lp1195800
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Seth Forshee (community) Approve
Review via email: mp+174000@code.launchpad.net

Commit message

Cleanup upstart job by removing unneeded environment variables and have the job respawn if powerd dies unexpectedly. Simplify the sigterm handler, which also removes the duplicate calls to unown name which were causing warnings.
Finally, fix LP: #1195800 by simply exiting if we lose or never get our dbus name.

Description of the change

Cleanup upstart job by removing unneeded environment variables. Also have the
job respawn if powerd dies unexpectedly. Simplify the sigterm handler, which
also removes the duplicate calls to unown name which were causing warnings.
Finally, fix LP: #1195800 by simply exiting if we lose or never get our
dbus name. This will cause the 2nd instance of powerd to bail, the first
instance will be left alone.

To post a comment you must log in.
lp:~mfisch/powerd/lp1195800 updated
64. By Matt Fischer

Fixing some CR comments. Disable debugging by default.

Revision history for this message
Seth Forshee (sforshee) :
review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
lp:~mfisch/powerd/lp1195800 updated
65. By Matt Fischer

Switching the logging to go to stderr when we lose the bus name and
have better exit codes now.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
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
1=== modified file 'debian/upstart'
2--- debian/upstart 2013-06-10 20:02:23 +0000
3+++ debian/upstart 2013-07-10 19:15:30 +0000
4@@ -2,28 +2,9 @@
5
6 start on started dbus
7
8-script
9-export HOSTNAME=android
10-export SHELL=/system/bin/sh
11-export TERM=vt100
12-export ANDROID_CACHE=/cache
13-export LOOP_MOUNTPOINT=/mnt/obb
14-export ASEC_MOUNTPOINT=/mnt/asec
15-export ANDROID_PROPERTY_WORKSPACE=8,49152
16-export ANDROID_ASSETS=/system/app
17-export ANDROID_BOOTLOGO=1
18-export USER=phablet
19-export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
20-export ANDROID_DATA=/data
21-export QT_QPA_PLATFORM=hybris
22-export SHLVL=1
23-export MKSH=/system/bin/sh
24-export ANDROID_ROOT=/system
25-export EXTERNAL_STORAGE=/mnt/sdcard
26-# for debugging purposes, remove when closer to shipping (mfisch)
27-export POWERD_DEBUG=1
28-
29-
30- exec /usr/bin/powerd
31-
32-end script
33+respawn
34+
35+#uncomment the line below to enable debugging
36+#env POWERD_DEBUG=1
37+
38+exec /usr/bin/powerd
39
40=== modified file 'src/powerd-internal.h'
41--- src/powerd-internal.h 2013-07-02 13:52:40 +0000
42+++ src/powerd-internal.h 2013-07-10 19:15:30 +0000
43@@ -57,7 +57,7 @@
44 GSList *uuids;
45 };
46
47-void powerd_exit(void);
48+void powerd_exit(int exit_code);
49 void powerd_reset_activity_timer(int add);
50 void powerd_dbus_init_complete(void);
51 int powerd_is_mainloop(void);
52
53=== modified file 'src/powerd-object.c'
54--- src/powerd-object.c 2013-07-01 21:28:26 +0000
55+++ src/powerd-object.c 2013-07-10 19:15:30 +0000
56@@ -20,6 +20,7 @@
57 #include <glib-object.h>
58 #include <gio/gio.h>
59 #include <string.h>
60+#include <stdio.h>
61 #include "powerd-internal.h"
62 #include "powerd-dbus.h"
63 #include "log.h"
64@@ -103,7 +104,7 @@
65 error->message);
66 g_error_free(error);
67 error = NULL;
68- powerd_exit();
69+ powerd_exit(-1);
70 }
71
72 g_signal_connect(G_OBJECT(powerd_source->priv->skel), "handle-request-sys-state",
73@@ -138,8 +139,8 @@
74 const gchar *name,
75 gpointer user_data)
76 {
77- powerd_warn("name lost (%s)", name);
78- //XXX - quit here
79+ fprintf(stderr, "dbus name lost or unable to acquire dbus name, is another copy of powerd running?\n");
80+ powerd_exit(-2);
81 }
82
83 void
84
85=== modified file 'src/powerd.cpp'
86--- src/powerd.cpp 2013-07-02 13:52:40 +0000
87+++ src/powerd.cpp 2013-07-10 19:15:30 +0000
88@@ -98,6 +98,8 @@
89 /* Assume screen starts off when powerd starts */
90 int activity_timer_screen_state = SCREEN_STATE_OFF;
91
92+static int g_exit_code = 0;
93+
94 /*
95 * Display request for activity timer
96 *
97@@ -204,10 +206,7 @@
98 sigterm_quit(int signal)
99 {
100 powerd_warn("SIGTERM recieved, cleaning up");
101- // XXX - strangely this call to unown name claims the id is invalid
102- // but I'm sure we're using it properly
103- g_bus_unown_name(name_id);
104- g_main_loop_quit(main_loop);
105+ powerd_exit(0);
106 }
107
108 int update_screen_state_worker(gpointer data)
109@@ -420,8 +419,9 @@
110 return (g_thread_self() == powerd_mainloop_thread);
111 }
112
113-void powerd_exit(void)
114+void powerd_exit(int exit_code)
115 {
116+ g_exit_code = exit_code;
117 g_main_loop_quit(main_loop);
118 }
119
120@@ -511,5 +511,5 @@
121 powerd_backlight_deinit();
122 display_request_deinit();
123 power_request_deinit();
124- return 0;
125+ return g_exit_code;
126 }

Subscribers

People subscribed via source and target branches