Merge "init: prevent action being added to the action_queue twice" into jb-mr2-dev
This commit is contained in:
commit
2fa2dfd105
1 changed files with 6 additions and 1 deletions
|
|
@ -571,6 +571,7 @@ void queue_builtin_action(int (*func)(int nargs, char **args), char *name)
|
||||||
act = calloc(1, sizeof(*act));
|
act = calloc(1, sizeof(*act));
|
||||||
act->name = name;
|
act->name = name;
|
||||||
list_init(&act->commands);
|
list_init(&act->commands);
|
||||||
|
list_init(&act->qlist);
|
||||||
|
|
||||||
cmd = calloc(1, sizeof(*cmd));
|
cmd = calloc(1, sizeof(*cmd));
|
||||||
cmd->func = func;
|
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)
|
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)
|
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 listnode *node = list_head(&action_queue);
|
||||||
struct action *act = node_to_item(node, struct action, qlist);
|
struct action *act = node_to_item(node, struct action, qlist);
|
||||||
list_remove(node);
|
list_remove(node);
|
||||||
|
list_init(node);
|
||||||
return act;
|
return act;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -825,6 +829,7 @@ static void *parse_action(struct parse_state *state, int nargs, char **args)
|
||||||
act = calloc(1, sizeof(*act));
|
act = calloc(1, sizeof(*act));
|
||||||
act->name = args[1];
|
act->name = args[1];
|
||||||
list_init(&act->commands);
|
list_init(&act->commands);
|
||||||
|
list_init(&act->qlist);
|
||||||
list_add_tail(&action_list, &act->alist);
|
list_add_tail(&action_list, &act->alist);
|
||||||
/* XXX add to hash */
|
/* XXX add to hash */
|
||||||
return act;
|
return act;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue