]> git.tuebingen.mpg.de Git - paraslash.git/commit
ao_write: Avoid segfault on exit.
authorAndre Noll <maan@systemlinux.org>
Mon, 3 Feb 2014 20:06:00 +0000 (21:06 +0100)
committerAndre Noll <maan@systemlinux.org>
Sun, 6 Apr 2014 06:53:26 +0000 (08:53 +0200)
commit5323dab36cfea7ee18f6ade7e38f1218cd7a9ea5
treeeae38649b133c0bc9c0b0672138cbc4dfa21ec98
parentd2c65fd068a5c2e7cde52bd06e1eadc7e7e37364
ao_write: Avoid segfault on exit.

If para_audiod is terminated by a signal it calls the ->close() method
of each active writer. In this method the ao writer calls ao_close()
and frees all resources but leaves the play thread active. So the
thread continues to run, prints

ao_alsa ERROR: write error: File descriptor in bad state

and probably crashes afterwards due to accessing freed memory. Fix this
by cancelling the thread in ->close() if it exists. Ironically enough,
this re-introduces a call to pthread_join(), but it's OK here since
we the cancelled thread should exit immediately (so we don't block),
and we are about to exit anyway.
ao_write.c