diff options
author | Thomas Adam <thomas@xteddy.org> | 2016-10-16 20:01:10 +0100 |
---|---|---|
committer | Thomas Adam <thomas@xteddy.org> | 2016-10-16 20:01:10 +0100 |
commit | c67b7025882ee6bc2b3d5112dbc630c191f1fa2a (patch) | |
tree | 4c36124e376eac0235accd523be6545ccdccf6af /cmd-source-file.c | |
parent | 3d8efdf310f475a6b9ed83814182c966de2bdab3 (diff) | |
parent | ddc4512d2e0eda6c705e002cb5dbf80719d709e1 (diff) | |
download | rtmux-c67b7025882ee6bc2b3d5112dbc630c191f1fa2a.tar.gz rtmux-c67b7025882ee6bc2b3d5112dbc630c191f1fa2a.tar.bz2 rtmux-c67b7025882ee6bc2b3d5112dbc630c191f1fa2a.zip |
Merge branch 'obsd-master'
Diffstat (limited to 'cmd-source-file.c')
-rw-r--r-- | cmd-source-file.c | 54 |
1 files changed, 16 insertions, 38 deletions
diff --git a/cmd-source-file.c b/cmd-source-file.c index 336a79e6..6f9c4451 100644 --- a/cmd-source-file.c +++ b/cmd-source-file.c @@ -28,7 +28,7 @@ static enum cmd_retval cmd_source_file_exec(struct cmd *, struct cmd_q *); -static void cmd_source_file_done(struct cmd_q *); +static enum cmd_retval cmd_source_file_done(struct cmd_q *, void *); const struct cmd_entry cmd_source_file_entry = { .name = "source-file", @@ -45,53 +45,31 @@ static enum cmd_retval cmd_source_file_exec(struct cmd *self, struct cmd_q *cmdq) { struct args *args = self->args; - struct cmd_q *cmdq1; + struct client *c = cmdq->client; int quiet; - - cmdq1 = cmdq_new(cmdq->client); - cmdq1->emptyfn = cmd_source_file_done; - cmdq1->data = cmdq; + struct cmd_q *new_cmdq; quiet = args_has(args, 'q'); - switch (load_cfg(args->argv[0], cmdq1, quiet)) { + switch (load_cfg(args->argv[0], c, cmdq, quiet)) { case -1: - cmdq_free(cmdq1); - if (cfg_references == 0) { + if (cfg_finished) cfg_print_causes(cmdq); - return (CMD_RETURN_ERROR); - } - return (CMD_RETURN_NORMAL); + return (CMD_RETURN_ERROR); case 0: - cmdq_free(cmdq1); - if (cfg_references == 0) + if (cfg_finished) cfg_print_causes(cmdq); return (CMD_RETURN_NORMAL); } - - log_debug("%s: cmdq %p, parent %p", __func__, cmdq1, cmdq); - - cmdq->references++; - cfg_references++; - - cmdq_continue(cmdq1); - return (CMD_RETURN_WAIT); + if (cfg_finished) { + new_cmdq = cmdq_get_callback(cmd_source_file_done, NULL); + cmdq_insert_after(cmdq, new_cmdq); + } + return (CMD_RETURN_NORMAL); } -static void -cmd_source_file_done(struct cmd_q *cmdq1) +static enum cmd_retval +cmd_source_file_done(struct cmd_q *cmdq, __unused void *data) { - struct cmd_q *cmdq = cmdq1->data; - - log_debug("%s: cmdq %p, parent %p", __func__, cmdq1, cmdq); - - if (cmdq1->client_exit >= 0) - cmdq->client_exit = cmdq1->client_exit; - cmdq_free(cmdq1); - - cfg_references--; - if (cmdq_free(cmdq)) - return; - if (cfg_references == 0) - cfg_print_causes(cmdq); - cmdq_continue(cmdq); + cfg_print_causes(cmdq); + return (CMD_RETURN_NORMAL); } |