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;
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();
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) {
{
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;
}, &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:
/** Paraslash user name. */
char *user;
/** The client task structure. */
- struct task task;
+ struct task *task;
/** List of features supported by the server. */
char **features;
};
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;
*/
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];
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);