summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2011-01-04 18:18:45 -0800
committerColin Cross <ccross@android.com>2011-01-04 18:21:22 -0800
commitf7ca6040616f672a6f0039d55e39c610b7c1cf91 (patch)
treec7ef22e5cff4199b8b2c4b3426586d87b7611a9c
parentb4d65399fde02280b718e3b5b5cb1464a885c4b0 (diff)
downloadcore-android-2.3.3_r1a.tar.gz
Fix infinite loop in init when debugging is turned offandroid-cts-2.3_r2android-2.3.3_r1aandroid-2.3.3_r1.1android-2.3.3_r1
If a keychord is pressed when debugging is turned off, the main event poll in init will return an event on the keychord fd, but handle_keychord never reads the data. Once this happens, the poll will always return immediately, and init enters an infinite loop. Fix it by always reading from the keychord fd, but only handling the returned keychord if debugging is enabled. Change-Id: Ie4efa98247d3cc978d275dc8a4516b32aa710278
-rw-r--r--init/keychords.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/init/keychords.c b/init/keychords.c
index 53ab39115..febb62fab 100644
--- a/init/keychords.c
+++ b/init/keychords.c
@@ -103,14 +103,14 @@ void handle_keychord()
// and on user builds for users that are developers.
debuggable = property_get("ro.debuggable");
adb_enabled = property_get("init.svc.adbd");
+ ret = read(keychord_fd, &id, sizeof(id));
+ if (ret != sizeof(id)) {
+ ERROR("could not read keychord id\n");
+ return;
+ }
+
if ((debuggable && !strcmp(debuggable, "1")) ||
(adb_enabled && !strcmp(adb_enabled, "running"))) {
- ret = read(keychord_fd, &id, sizeof(id));
- if (ret != sizeof(id)) {
- ERROR("could not read keychord id\n");
- return;
- }
-
svc = service_find_by_keychord(id);
if (svc) {
INFO("starting service %s from keychord\n", svc->name);