]> git.tuebingen.mpg.de Git - paraslash.git/commit
audiod: Clean up by notifying tasks.
authorAndre Noll <maan@systemlinux.org>
Wed, 1 Jan 2014 22:15:02 +0000 (22:15 +0000)
committerAndre Noll <maan@systemlinux.org>
Wed, 13 Aug 2014 06:44:19 +0000 (08:44 +0200)
commit751fface082c907983978023bdcb43540a462192
tree478629997b5519377af3d45d1b9bee6a8fd42c03
parent197a489a36e7b11264c87aeae67f3553172e598c
audiod: Clean up by notifying tasks.

There are two ways to terminate para_audiod in a controlled way:
by executing the "term" command and by sending SIGINT or SIGTERM
to the process. Currently both code paths call clean_exit() from
some ->post_select function, which terminates para_audiod by calling
exit(3). Despite the name, this is "unclean" because tasks are not shut
down properly, so not all memory can be freed by this approach. While
this is not a big problem, it makes it more difficult to debug real
memory leaks.

This patch tries to overcome this problem by using notifications to
shut down the audiod tasks. Two new error codes E_AUDIOD_TERM and
E_AUDIOD_SIGNAL are introduced for the notification values. All tasks
are modified to check for notifications and now return the (negative)
notification value from their ->post_select() method if a notification
was received. Hence schedule() returns to main() and we may clean up
the resources allocated by the scheduler by calling sched_shutdown(),
along with the usual cleanup performed by clean_exit(). The latter
function is renamed to audiod_cleanup(), which is more to the point.
audiod.c
audiod_command.c
error.h