]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - client.c
task_register() conversion: client task
[paraslash.git] / client.c
index d951692caa22f11340dcae3e29962aec2e5aa0ec..88b1e93a024f7028709614be0b2e763d1091697d 100644 (file)
--- a/client.c
+++ b/client.c
@@ -530,16 +530,15 @@ __noreturn static void print_completions(void)
 
 struct supervisor_task {
        bool stdout_task_started;
-       struct task task;
+       struct task *task;
 };
 
 static int supervisor_post_select(struct sched *s, struct task *t)
 {
-       struct supervisor_task *svt = container_of(t, struct supervisor_task,
-               task);
+       struct supervisor_task *svt = task_context(t);
 
-       if (ct->task.error < 0)
-               return ct->task.error;
+       if (ct->task->error < 0)
+               return ct->task->error;
        if (!svt->stdout_task_started && ct->status == CL_EXECUTING) {
                stdout_task_register(&sot, s);
                svt->stdout_task_started = true;
@@ -552,12 +551,7 @@ static int supervisor_post_select(struct sched *s, struct task *t)
        return 0;
 }
 
-static struct supervisor_task supervisor_task = {
-       .task = {
-               .post_select = supervisor_post_select,
-               .status = "supervisor task"
-       }
-};
+static struct supervisor_task supervisor_task;
 
 /**
  * The client program to connect to para_server.
@@ -605,10 +599,15 @@ int main(int argc, char *argv[])
                goto out;
        sot.btrn = btr_new_node(&(struct btr_node_description)
                EMBRACE(.name = "stdout", .parent = ct->btrn[0]));
-       register_task(&sched, &supervisor_task.task);
+       supervisor_task.task = task_register(&(struct task_info) {
+               .name = "supervisor",
+               .post_select = supervisor_post_select,
+               .context = &supervisor_task,
+       }, &sched);
+
        ret = schedule(&sched);
-       if (ret >= 0 && ct->task.error < 0) {
-               switch(ct->task.error) {
+       if (ret >= 0 && ct->task->error < 0) {
+               switch (ct->task->error) {
                /* these are not errors */
                case -E_SERVER_CMD_SUCCESS:
                case -E_EOF: