]> git.tue.mpg.de Git - paraslash.git/commitdiff
Fix a bug in para_write.
authorAndre Noll <maan@systemlinux.org>
Sat, 12 Jul 2008 10:40:36 +0000 (12:40 +0200)
committerAndre Noll <maan@systemlinux.org>
Sat, 12 Jul 2008 10:40:36 +0000 (12:40 +0200)
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.

write.h
write_common.c

diff --git a/write.h b/write.h
index a73ada5d06039b0d9c175c3266b581dd0a79d689..091f8c77181cbf3f1a014e31db2667b534aa5b0d 100644 (file)
--- 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 */
index 70a9a0155ff4e0a9e1f9b5bccf1054f1ea7a5275..3bf5d1199f560e9ce93b7d97a06e278ce495591f 100644 (file)
@@ -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) {