From 33d9e48b9ebe11858e4fd208196c419b72db7f6d Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Mon, 30 Dec 2013 22:23:31 +0000 Subject: [PATCH] task_register() conversion: audioc task --- audioc.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/audioc.c b/audioc.c index 5f6b5ae1..ab7253f6 100644 --- a/audioc.c +++ b/audioc.c @@ -79,7 +79,7 @@ static struct sched sched; struct audioc_task { int fd; struct btr_node *btrn; - struct task task; + struct task *task; }; static struct i9e_completer audiod_completers[]; @@ -123,7 +123,7 @@ static struct i9e_completer audiod_completers[] = { static void audioc_pre_select(struct sched *s, struct task *t) { - struct audioc_task *at = container_of(t, struct audioc_task, task); + struct audioc_task *at = task_context(t); int ret = btr_node_status(at->btrn, 0, BTR_NT_ROOT); if (ret < 0) @@ -134,7 +134,7 @@ static void audioc_pre_select(struct sched *s, struct task *t) static int audioc_post_select(struct sched *s, struct task *t) { char *buf = NULL; - struct audioc_task *at = container_of(t, struct audioc_task, task); + struct audioc_task *at = task_context(t); int ret = btr_node_status(at->btrn, 0, BTR_NT_ROOT); if (ret < 0) @@ -159,13 +159,7 @@ out: return ret; } -static struct audioc_task audioc_task = { - .task = { - .pre_select = audioc_pre_select, - .post_select = audioc_post_select, - .status = "audioc task" - }, -}, *at = &audioc_task; +static struct audioc_task audioc_task, *at = &audioc_task; static int audioc_i9e_line_handler(char *line) { @@ -193,8 +187,12 @@ static int audioc_i9e_line_handler(char *line) args = NULL; at->btrn = btr_new_node(&(struct btr_node_description) EMBRACE(.name = "audioc line handler")); - at->task.error = 0; - register_task(&sched, &at->task); + at->task = task_register(&(struct task_info) { + .name = "audioc", + .pre_select = audioc_pre_select, + .post_select = audioc_post_select, + .context = at, + }, &sched); i9e_attach_to_stdout(at->btrn); return 1; close: @@ -239,6 +237,7 @@ __noreturn static void interactive_session(void) goto out; para_log = i9e_log; ret = schedule(&sched); + sched_shutdown(&sched); i9e_close(); para_log = stderr_log; out: -- 2.39.5