[pulseaudio-discuss] [PATCH] core: Fix srbchannel error path of do_read()

David Henningsson david.henningsson at canonical.com
Fri Jun 20 01:53:05 PDT 2014



On 2014-06-17 16:10, Peter Meerwald wrote:
> From: Peter Meerwald <p.meerwald at bct-electronic.com>
>
> memblock.c: Assertion 'pa_atomic_load(&b->n_acquired) == 0'
> failed at pulsecore/memblock.c:532, function memblock_free(). Aborting.
>
> the reason is that re->memblock is acquired, but not released
>
> the fail exit path releases the memblock if necessary

Aha, thanks for finding it. Indeed there is an unmatched 
pa_memblock_acquire.

> the return value of 1 looks suspicious too (should be -1 or 0 I think)

Well, if pa_srbchannel_read returns 0, it means that there is currently 
nothing to read. So it isn't a "fail". So I couldn't return 0 (means 
continue reading), couldn't return -1 (means failure), so I chose 1.

But documenting this choice wouldn't hurt, I guess...

>
> Signed-off-by: Peter Meerwald <pmeerw at pmeerw.net>
> ---
>   src/pulsecore/pstream.c |    2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/pulsecore/pstream.c b/src/pulsecore/pstream.c
> index 505a5e0..57aad43 100644
> --- a/src/pulsecore/pstream.c
> +++ b/src/pulsecore/pstream.c
> @@ -711,7 +711,7 @@ static int do_read(pa_pstream *p, struct pstream_read *re) {
>       if (re == &p->readsr) {
>           r = pa_srbchannel_read(p->sr, d, l);
>           if (r == 0)
> -            return 1;
> +            goto fail;
>       }
>       else
>   #ifdef HAVE_CREDS
>

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


More information about the pulseaudio-discuss mailing list