ao_write: Join threads before returning an error from aow_post_select().
authorAndre Noll <maan@systemlinux.org>
Sun, 9 Mar 2014 14:21:00 +0000 (15:21 +0100)
committerAndre Noll <maan@systemlinux.org>
Sun, 6 Apr 2014 06:53:26 +0000 (08:53 +0200)
This guarantees the play thread is not active any more in aow_close().

ao_write.c

index af68824..4281f53 100644 (file)
@@ -40,10 +40,7 @@ static void aow_close(struct writer_node *wn)
 
        if (!pawd)
                return;
-       if (pawd->thread_btrn) {
-               pthread_cancel(pawd->thread);
-               pthread_join(pawd->thread, NULL);
-       }
+       assert(!pawd->thread_btrn);
        ao_close(pawd->dev);
        free(pawd);
        wn->private_data = NULL;
@@ -352,8 +349,10 @@ static int aow_post_select(__a_unused struct sched *s,
                return 0;
        }
        if (!wn->btrn) {
-               if (!pawd->thread_btrn)
+               if (!pawd->thread_btrn) {
+                       pthread_join(pawd->thread, NULL);
                        return -E_AO_EOF;
+               }
                PARA_INFO_LOG("waiting for play thread to terminate\n");
                return 0;
        }