]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
task_register() conversion: client exec task
authorAndre Noll <maan@systemlinux.org>
Mon, 30 Dec 2013 23:39:17 +0000 (23:39 +0000)
committerAndre Noll <maan@systemlinux.org>
Sun, 25 May 2014 13:39:00 +0000 (15:39 +0200)
client.c

index 349f970d961b52f78ad6d67ddf673a2fbb7b0d97..d951692caa22f11340dcae3e29962aec2e5aa0ec 100644 (file)
--- 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;