ao_write: Call ao_initialize() only once.
authorAndre Noll <maan@systemlinux.org>
Sun, 9 Mar 2014 14:21:48 +0000 (15:21 +0100)
committerAndre Noll <maan@systemlinux.org>
Sun, 6 Apr 2014 06:53:26 +0000 (08:53 +0200)
It is possible that another instance of the ao writer is active
when aow_close() is called. Calling ao_shutdown() in ao_close()
might disturb the other instance and lead to a segmentation fault.

Fix this by calling ao_initialize() only once during aow_init()
and never call ao_shutdown() any more.

ao_write.c

index 4281f536d87ffaa58f3621c0edf95535893188ca..63d18afab387288831e45e50cd33ecfd42801805 100644 (file)
@@ -44,7 +44,6 @@ static void aow_close(struct writer_node *wn)
        ao_close(pawd->dev);
        free(pawd);
        wn->private_data = NULL;
-       ao_shutdown();
 }
 
 static void aow_pre_select(struct sched *s, struct task *t)
@@ -158,7 +157,6 @@ static int aow_init(struct writer_node *wn, unsigned sample_rate,
        struct private_aow_data *pawd = para_malloc(sizeof(*pawd));
        struct ao_write_args_info *conf = wn->conf;
 
-       ao_initialize();
        if (conf->driver_given) {
                ret = -E_AO_BAD_DRIVER;
                id = ao_driver_id(conf->driver_arg);
@@ -455,6 +453,5 @@ void ao_write_init(struct writer *w)
        dh[num_lines] = NULL;
        w->help.detailed_help = (const char **)dh;
        ao_write_cmdline_parser_free(&dummy);
-       ao_shutdown();
 }