diff options
| author | Colin Cross <ccross@android.com> | 2013-03-07 13:42:29 -0800 |
|---|---|---|
| committer | Colin Cross <ccross@android.com> | 2013-06-10 14:16:00 -0700 |
| commit | e9ab162f30e88d5d9f8a9264d83745b8c3f381ad (patch) | |
| tree | 51ae47bc98746b5caa9be168fc1bfad56dcfa0ba | |
| parent | 59fa7e107d43a4ef521413ec0bb7b0c2a5525071 (diff) | |
| download | system_core-e9ab162f30e88d5d9f8a9264d83745b8c3f381ad.zip system_core-e9ab162f30e88d5d9f8a9264d83745b8c3f381ad.tar.gz system_core-e9ab162f30e88d5d9f8a9264d83745b8c3f381ad.tar.bz2 | |
init: prevent action being added to the action_queue twice
Property triggers may cause an action to be queued twice, resulting
in a loop in the action queue. Keep actions that are not on the queue
in the list_empty state (act->qlist->next == act->qlist), and only
add them to the list if they are in that state.
Bug: 8335133
Change-Id: I3a3ec18176cf19cbaa3a45220a03c7560eacfe79
| -rw-r--r-- | init/init_parser.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/init/init_parser.c b/init/init_parser.c index beb9188..686640e 100644 --- a/init/init_parser.c +++ b/init/init_parser.c @@ -571,6 +571,7 @@ void queue_builtin_action(int (*func)(int nargs, char **args), char *name) act = calloc(1, sizeof(*act)); act->name = name; list_init(&act->commands); + list_init(&act->qlist); cmd = calloc(1, sizeof(*cmd)); cmd->func = func; @@ -583,7 +584,9 @@ void queue_builtin_action(int (*func)(int nargs, char **args), char *name) void action_add_queue_tail(struct action *act) { - list_add_tail(&action_queue, &act->qlist); + if (list_empty(&act->qlist)) { + list_add_tail(&action_queue, &act->qlist); + } } struct action *action_remove_queue_head(void) @@ -594,6 +597,7 @@ struct action *action_remove_queue_head(void) struct listnode *node = list_head(&action_queue); struct action *act = node_to_item(node, struct action, qlist); list_remove(node); + list_init(node); return act; } } @@ -825,6 +829,7 @@ static void *parse_action(struct parse_state *state, int nargs, char **args) act = calloc(1, sizeof(*act)); act->name = args[1]; list_init(&act->commands); + list_init(&act->qlist); list_add_tail(&action_list, &act->alist); /* XXX add to hash */ return act; |
