Re: [PATCH] pcm: Fix shm initialization race-condition

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

 



On Sun, 14 Aug 2016 02:28:52 +0200,
Ismael Luceno wrote:
> 
> Easily seen when two threads try at the same time, one of them will fail.
> 
> The bug was identified by using apulse with Skype.
> 
> Fixes: dec428c35221 ("pcm: fix 'unable to create IPC shm instance' caused by fork from a thread")
> Fixes: https://github.com/i-rinat/apulse/issues/38
> Signed-off-by: Ismael Luceno <ismael@xxxxxxxxxxx>
> ---
>  src/pcm/pcm_direct.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/src/pcm/pcm_direct.c b/src/pcm/pcm_direct.c
> index c3925cc20fd3..b5215ba35406 100644
> --- a/src/pcm/pcm_direct.c
> +++ b/src/pcm/pcm_direct.c
> @@ -101,6 +101,8 @@ retryget:
>  		if ((dmix->shmid = shmget(dmix->ipc_key, sizeof(snd_pcm_direct_share_t),
>  					     IPC_CREAT | IPC_EXCL | dmix->ipc_perm)) != -1)
>  			first_instance = 1;
> +		if (dmix->shmid < 0 && errno == EEXIST)
> +			goto retryget;

Hrm, but this would result in an endless loop if the shm was already
taken persistently.

Also, which call does give a negative shmid, actually?  It's from the
first shmget() or the second shmget()?
(The existing code is ugly and we need to fix the indentation
 there...)


thanks,

Takashi
_______________________________________________
Alsa-devel mailing list
Alsa-devel@xxxxxxxxxxxxxxxx
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel



[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux