[PATCH] thread-mq: make pa_thread_mq_done() safe for subsequent calls

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 05/14/2013 04:09 PM, Tanu Kaskinen wrote:
> From: Janos Kovacs <jankovac503 at gmail.com>
>
> ---
>   src/pulsecore/thread-mq.c | 8 ++++++++
>   1 file changed, 8 insertions(+)
>
> diff --git a/src/pulsecore/thread-mq.c b/src/pulsecore/thread-mq.c
> index b492793..9efcd8a 100644
> --- a/src/pulsecore/thread-mq.c
> +++ b/src/pulsecore/thread-mq.c
> @@ -97,6 +97,14 @@ void pa_thread_mq_init(pa_thread_mq *q, pa_mainloop_api *mainloop, pa_rtpoll *rt
>   void pa_thread_mq_done(pa_thread_mq *q) {
>       pa_assert(q);
>
> +    if (!q->mainloop && !q->inq && !q->outq &&
> +        !q->read_event && !q->write_event)
> +        return;
> +
> +    pa_assert(q->mainloop);
> +    pa_assert(q->inq && q->outq);
> +    pa_assert(q->read_event && q->write_event);
> +
>       /* Since we are called from main context we can be sure that the
>        * inq is empty. However, the outq might still contain messages
>        * for the main loop, which we need to dispatch (e.g. release
>

Looks a bit weird. There's no explanation if this fixes an existing bug 
or just some attempt to be safer for the future.

Anyway, feels like it would have been better to put if's around every 
call instead, because rest of PulseAudio is coded that way. E g:

if (q->mainloop && q->read_event) {
     q->mainloop->io_free(q->read_event);
     q->read_event = NULL;
}





-- 
David Henningsson, Canonical Ltd.
https://launchpad.net/~diwic


[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux