From: Andre Noll Date: Sun, 9 Mar 2014 14:21:00 +0000 (+0100) Subject: ao_write: Join threads before returning an error from aow_post_select(). X-Git-Tag: v0.5.3~20^2~1 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=955705a4ef6b69e246914ed6330a713b4c13ccf4 ao_write: Join threads before returning an error from aow_post_select(). This guarantees the play thread is not active any more in aow_close(). --- diff --git a/ao_write.c b/ao_write.c index af688242..4281f536 100644 --- a/ao_write.c +++ b/ao_write.c @@ -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; }