From: Andre Noll Date: Mon, 30 Dec 2013 23:39:17 +0000 (+0000) Subject: task_register() conversion: client exec task X-Git-Tag: v0.5.3~8^2~17 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=f3f25455d91c6d8fa7789abce1f7c536436beead;p=paraslash.git task_register() conversion: client exec task --- diff --git a/client.c b/client.c index 349f970d..d951692c 100644 --- a/client.c +++ b/client.c @@ -39,7 +39,7 @@ __printf_2_3 void (*para_log)(int, const char*, ...) = stderr_log; #include "afs_completion.h" struct exec_task { - struct task task; + struct task *task; struct btr_node *btrn; char *result_buf; size_t result_size; @@ -47,7 +47,7 @@ struct exec_task { static void exec_pre_select(struct sched *s, struct task *t) { - struct exec_task *et = container_of(t, struct exec_task, task); + struct exec_task *et = task_context(t); int ret = btr_node_status(et->btrn, 0, BTR_NT_LEAF); if (ret != 0) @@ -56,7 +56,7 @@ static void exec_pre_select(struct sched *s, struct task *t) static int exec_post_select(__a_unused struct sched *s, struct task *t) { - struct exec_task *et = container_of(t, struct exec_task, task); + struct exec_task *et = task_context(t); struct btr_node *btrn = et->btrn; char *buf; size_t sz; @@ -93,11 +93,6 @@ static int execute_client_command(const char *cmd, char **result) int ret; struct sched command_sched = {.default_timeout = {.tv_sec = 1}}; struct exec_task exec_task = { - .task = { - .pre_select = exec_pre_select, - .post_select = exec_post_select, - .status = "client exec task", - }, .result_buf = para_strdup(""), .result_size = 1, }; @@ -107,11 +102,17 @@ static int execute_client_command(const char *cmd, char **result) goto out; exec_task.btrn = btr_new_node(&(struct btr_node_description) EMBRACE(.name = "exec_collect")); - register_task(&command_sched, &exec_task.task); + exec_task.task = task_register(&(struct task_info) { + .name = "client exec", + .pre_select = exec_pre_select, + .post_select = exec_post_select, + .context = &exec_task, + }, &command_sched); ret = client_connect(ct, &command_sched, NULL, exec_task.btrn); if (ret < 0) goto out; schedule(&command_sched); + sched_shutdown(&command_sched); *result = exec_task.result_buf; btr_remove_node(&exec_task.btrn); ret = 1;