From: Andre Date: Wed, 31 May 2006 21:03:19 +0000 (+0200) Subject: Fix wng_open error handling. X-Git-Tag: v0.2.14~92 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=c47cdc9856a174a06a8ebe30018b20a22fe234fd;p=paraslash.git Fix wng_open error handling. if wn->open() failed, undo all work and set the eof flag in the wng. --- diff --git a/audiod.c b/audiod.c index 8f6f3560..68c84fb4 100644 --- a/audiod.c +++ b/audiod.c @@ -105,7 +105,7 @@ static char *af_status, /* the audio format announced in server status */ *socket_name, *hostname; static char *stat_item_values[NUM_STAT_ITEMS]; static FILE *logfile; -static const struct timeval restart_delay = {0, 300 * 1000}; +static const struct timeval restart_delay = {0, 200 * 1000}; static struct audio_format_info afi[NUM_AUDIO_FORMATS]; static struct timeval *now; @@ -718,7 +718,11 @@ static void open_writers(int slot_num) s->wng->writer_nodes[i].writer = a->writers[i]; sprintf(s->wng->writer_nodes[i].task.status, "writer_node"); } - ret = wng_open(s->wng); /* FIXME */ + ret = wng_open(s->wng); + if (ret < 0) { + PARA_ERROR_LOG("%s\n", PARA_STRERROR(-ret)); + return; + } s->wstime = *now; current_decoder = slot_num; activate_inactive_grab_clients(slot_num, s->format, &s->fc->filters); @@ -816,7 +820,7 @@ static void compute_time_diff(const struct timeval *status_time) count > 10? sign : sign * time_smooth, &diff, &tmp); sa_time_diff = tmp; - PARA_INFO_LOG("time diff (cur/avg): %s%lums/%s%lums\n", + PARA_DEBUG_LOG("time diff (cur/avg): %s%lums/%s%lums\n", sign > 0? "+" : "-", tv2ms(&diff), sa_time_diff_sign ? "+" : "-", diff --git a/filter_chain.c b/filter_chain.c index db0a4c00..4114ca77 100644 --- a/filter_chain.c +++ b/filter_chain.c @@ -124,6 +124,8 @@ void filter_pre_select(__a_unused struct sched *s, struct task *t) t->ret = -E_FC_EOF; if (fc->output_eof && *fc->output_eof) goto err_out; + if (fc->input_eof && *fc->input_eof) + goto err_out; again: ib = fc->inbuf; loaded = fc->in_loaded; diff --git a/write_common.c b/write_common.c index dda60168..a413d47e 100644 --- a/write_common.c +++ b/write_common.c @@ -66,7 +66,7 @@ int wng_open(struct writer_node_group *g) wn->wng = g; ret = wn->writer->open(wn); if (ret < 0) - goto out; + goto err_out; wn->chunk_bytes = ret; g->max_chunk_bytes = PARA_MAX(g->max_chunk_bytes, ret); wn->task.pre_select = wn->writer->pre_select; @@ -75,9 +75,17 @@ int wng_open(struct writer_node_group *g) register_task(&wn->task); } sprintf(g->task.status, "%s", "writer node group"); - g->eof = 0; register_task(&g->task); -out: + g->eof = 0; + return 1; +err_out: + while (i > 0) { + struct writer_node *wn = &g->writer_nodes[--i]; + unregister_task(&wn->task); + wn->writer->close(wn); + } + g->num_writers = 0; + g->eof = 1; return ret; }