X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=write.c;h=62caf09757ec52d45f825698d7f4656696d7bcff;hp=6799db4175282b779c2fd454d11988be31b933d8;hb=dda88dcb390a44e1f1f68f6248ed513c75dce4bf;hpb=9d75ded33ce6664156acb07e311f51d55970bbea diff --git a/write.c b/write.c index 6799db41..62caf097 100644 --- a/write.c +++ b/write.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2013 Andre Noll + * Copyright (C) 2005 Andre Noll * * Licensed under the GPL v2. For licencing details see COPYING. */ @@ -24,7 +24,8 @@ #include "version.h" #include "check_wav.h" -INIT_WRITE_ERRLISTS; +/** Array of error strings. */ +DEFINE_PARA_ERRLIST; static struct write_args_info conf; @@ -71,19 +72,19 @@ static void setup_writer_node(const char *arg, struct btr_node *parent, } struct write_task { - struct task task; + struct task *task; struct check_wav_context *cwc; }; -static void write_pre_select(struct sched *s, struct task *t) +static void write_pre_select(struct sched *s, void *context) { - struct write_task *wt = container_of(t, struct write_task, task); + struct write_task *wt = context; check_wav_pre_select(s, wt->cwc); } -static int write_post_select(__a_unused struct sched *s, struct task *t) +static int write_post_select(__a_unused struct sched *s, void *context) { - struct write_task *wt = container_of(t, struct write_task, task); + struct write_task *wt = context; return check_wav_post_select(wt->cwc); } @@ -94,22 +95,20 @@ static int setup_and_schedule(void) struct writer_node *wns; static struct sched s; struct wav_params wp; - struct write_task wt = { - .task = { - .pre_select = write_pre_select, - .post_select = write_post_select, - .status = "write task", - }, - }; + struct write_task wt; sit.btrn = btr_new_node(&(struct btr_node_description) EMBRACE(.name = "stdin")); - stdin_set_defaults(&sit); - register_task(&s, &sit.task); + stdin_task_register(&sit, &s); COPY_WAV_PARMS(&wp, &conf); wt.cwc = check_wav_init(sit.btrn, NULL, &wp, &cw_btrn); - register_task(&s, &wt.task); + wt.task = task_register(&(struct task_info) { + .name = "write", + .pre_select = write_pre_select, + .post_select = write_post_select, + .context = &wt, + }, &s); if (!conf.writer_given) { wns = para_calloc(sizeof(*wns)); setup_writer_node(NULL, cw_btrn, wns, &s); @@ -125,16 +124,17 @@ static int setup_and_schedule(void) s.default_timeout.tv_usec = 50000; ret = schedule(&s); if (ret >= 0) { - int j; + int j, ts; for (j = 0; j < i; j++) { - struct task *t = &wns[j].task; - assert(t->error < 0); - if (t->error != -E_WRITE_COMMON_EOF - && t->error != -E_BTR_EOF) { - PARA_ERROR_LOG("%s: %s\n", t->status, - para_strerror(-t->error)); + struct writer_node *wn = wns + j; + ts = task_status(wn->task); + assert(ts < 0); + if (ts != -E_WRITE_COMMON_EOF && ts != -E_BTR_EOF) { + const char *name = writer_names[wn->writer_num]; + PARA_ERROR_LOG("%s: %s\n", name, + para_strerror(-ts)); if (ret >= 0) - ret = t->error; + ret = ts; } } } @@ -149,6 +149,7 @@ static int setup_and_schedule(void) } free(wns); check_wav_shutdown(wt.cwc); + sched_shutdown(&s); return ret; }