From: Andre Noll Date: Sat, 12 Jul 2008 10:40:36 +0000 (+0200) Subject: Fix a bug in para_write. X-Git-Tag: v0.3.3~50^2~1 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=4a562d17319e990f75ea3bbf5f3e25bfe0aafba7;p=paraslash.git Fix a bug in para_write. With the old code, the command "para_write < /dev/null" would segfault because the wng_close() is called although the writer node group was never opened. Fix this bug by introducing a new field in struct writer_node_group that tracks whether wng_open() was called. --- diff --git a/write.h b/write.h index a73ada5d..091f8c77 100644 --- a/write.h +++ b/write.h @@ -113,6 +113,8 @@ struct writer_node_group { unsigned int *samplerate; /** the task associated to this group */ struct task task; + /** Whether the group is open, i.e. wng_open() was called. */ + int open; }; /** loop over each writer node in a writer group */ diff --git a/write_common.c b/write_common.c index 70a9a015..3bf5d119 100644 --- a/write_common.c +++ b/write_common.c @@ -90,6 +90,7 @@ int wng_open(struct writer_node_group *g) } sprintf(g->task.status, "%s", "writer node group"); register_task(&g->task); + g->open = 1; return 1; err_out: PARA_ERROR_LOG("%s\n", para_strerror(-ret)); @@ -112,7 +113,7 @@ void wng_close(struct writer_node_group *g) { int i; - if (!g) + if (!g || !g->open) return; PARA_NOTICE_LOG("closing wng with %d writer(s)\n", g->num_writers); FOR_EACH_WRITER_NODE(i, g) {