From ddc4512d2e0eda6c705e002cb5dbf80719d709e1 Mon Sep 17 00:00:00 2001 From: nicm Date: Sun, 16 Oct 2016 17:55:14 +0000 Subject: Rewrite command queue handling. Each client still has a command queue, but there is also now a global command queue. Instead of command queues being dispatched on demand from wherever the command happens to be added, they are now all dispatched from the top level server loop. Command queues may now also include callbacks as well as commands, and items may be inserted after the current command as well as at the end. This all makes command queues significantly more predictable and easier to use, and avoids the complex multiple nested command queues used by source-file, if-shell and friends. A mass rename of struct cmdq to a better name (cmdq_item probably) is coming. --- notify.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'notify.c') diff --git a/notify.c b/notify.c index 416b81f6..a75b3182 100644 --- a/notify.c +++ b/notify.c @@ -66,7 +66,7 @@ notify_hook(struct notify_entry *ne) const char *name; struct cmd_find_state fs; struct hook *hook; - struct cmd_q *hooks_cmdq; + struct cmd_q *new_cmdq, *loop; name = notify_hooks[ne->type]; if (name == NULL) @@ -87,14 +87,12 @@ notify_hook(struct notify_entry *ne) return; log_debug("notify hook %s", name); - hooks_cmdq = cmdq_new(NULL); - hooks_cmdq->flags |= CMD_Q_NOHOOKS; + new_cmdq = cmdq_get_command(hook->cmdlist, &fs, NULL, CMD_Q_NOHOOKS); - cmd_find_copy_state(&hooks_cmdq->current, &fs); - hooks_cmdq->parent = NULL; + for (loop = new_cmdq; loop != NULL; loop = loop->next) + loop->hook = xstrdup(name); - cmdq_run(hooks_cmdq, hook->cmdlist, NULL); - cmdq_free(hooks_cmdq); + cmdq_append(NULL, new_cmdq); } static void -- cgit v1.2.3