From: Andre Noll Date: Mon, 30 Dec 2013 23:54:26 +0000 (+0000) Subject: task_register() conversion: client task X-Git-Tag: v0.5.3~8^2~15 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=0b43ec5dfd9e301257e3c0b31733ea67c1db4426;p=paraslash.git task_register() conversion: client task --- diff --git a/audiod.c b/audiod.c index afdb97f7..948204dc 100644 --- a/audiod.c +++ b/audiod.c @@ -1081,6 +1081,7 @@ static void close_stat_pipe(void) if (!stat_task->ct) return; client_close(stat_task->ct); + task_reap(&stat_task->ct->task); stat_task->ct = NULL; clear_and_dump_items(); stat_task->length_seconds = 0; @@ -1231,8 +1232,8 @@ static int status_post_select(struct sched *s, struct task *t) if (audiod_status == AUDIOD_OFF) { if (!st->ct) goto out; - if (st->ct->task.error >= 0) { - task_notify(&st->ct->task, E_AUDIOD_OFF); + if (st->ct->task->error >= 0) { + task_notify(st->ct->task, E_AUDIOD_OFF); goto out; } close_stat_pipe(); @@ -1255,14 +1256,14 @@ static int status_post_select(struct sched *s, struct task *t) struct timeval diff; tv_diff(now, &st->last_status_read, &diff); if (diff.tv_sec > 61) - task_notify(&st->ct->task, E_STATUS_TIMEOUT); + task_notify(st->ct->task, E_STATUS_TIMEOUT); goto out; } btr_merge(st->btrn, st->min_iqs); sz = btr_next_buffer(st->btrn, &buf); ret = for_each_stat_item(buf, sz, update_item); if (ret < 0) { - task_notify(&st->ct->task, -ret); + task_notify(st->ct->task, -ret); goto out; } if (sz != ret) { diff --git a/client.c b/client.c index d3ad23a4..88b1e93a 100644 --- a/client.c +++ b/client.c @@ -537,8 +537,8 @@ static int supervisor_post_select(struct sched *s, struct task *t) { 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; @@ -606,8 +606,8 @@ int main(int argc, char *argv[]) }, &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: diff --git a/client.h b/client.h index e304f092..0a0c55cb 100644 --- a/client.h +++ b/client.h @@ -47,7 +47,7 @@ struct client_task { /** Paraslash user name. */ char *user; /** The client task structure. */ - struct task task; + struct task *task; /** List of features supported by the server. */ char **features; }; diff --git a/client_common.c b/client_common.c index 8212abb1..df279129 100644 --- a/client_common.c +++ b/client_common.c @@ -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);