From: Andre Noll Date: Wed, 1 Jan 2014 22:15:02 +0000 (+0000) Subject: audiod: Clean up by notifying tasks. X-Git-Tag: v0.5.4~49^2 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=751fface082c907983978023bdcb43540a462192;hp=751fface082c907983978023bdcb43540a462192 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. ---