]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - client_common.c
task_register() conversion: client task
[paraslash.git] / client_common.c
index 8212abb1d611dcff88889fa70629fcdc9f6eb5cf..df279129411b9cfaca3d7529654e59509b11029b 100644 (file)
@@ -70,7 +70,7 @@ void client_close(struct client_task *ct)
 static void client_pre_select(struct sched *s, struct task *t)
 {
        int ret;
-       struct client_task *ct = container_of(t, struct client_task, task);
+       struct client_task *ct = task_context(t);
 
        if (ct->scc.fd < 0)
                return;
@@ -283,7 +283,7 @@ static int send_sb_command(struct client_task *ct)
  */
 static int client_post_select(struct sched *s, struct task *t)
 {
-       struct client_task *ct = container_of(t, struct client_task, task);
+       struct client_task *ct = task_context(t);
        int ret = 0;
        size_t n;
        char buf[CLIENT_BUFSIZE];
@@ -496,11 +496,13 @@ int client_connect(struct client_task *ct, struct sched *s,
                EMBRACE(.name = "client recv", .parent = NULL, .child = child));
        ct->btrn[1] = btr_new_node(&(struct btr_node_description)
                EMBRACE(.name = "client send", .parent = parent, .child = NULL));
-       ct->task.pre_select = client_pre_select;
-       ct->task.post_select = client_post_select;
-       ct->task.error = 0;
-       sprintf(ct->task.status, "client");
-       register_task(s, &ct->task);
+
+       ct->task = task_register(&(struct task_info) {
+               .name = "client",
+               .pre_select = client_pre_select,
+               .post_select = client_post_select,
+               .context = ct,
+       }, s);
        return 1;
 err_out:
        close(ct->scc.fd);