Skip to content

Commit

Permalink
Fix infinite loop in init when debugging is turned off
Browse files Browse the repository at this point in the history
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
  • Loading branch information
colincross committed Jan 5, 2011
1 parent b4d6539 commit f7ca604
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions init/keychords.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit f7ca604

Please sign in to comment.