mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-06 13:29:59 -05:00
pcm: Fix shm initialization race-condition
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: dec428c352 ("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@iodev.co.uk>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
e2cfe3c6c8
commit
7640856769
1 changed files with 3 additions and 2 deletions
|
|
@ -96,11 +96,12 @@ int snd_pcm_direct_shm_create_or_connect(snd_pcm_direct_t *dmix)
|
|||
retryget:
|
||||
dmix->shmid = shmget(dmix->ipc_key, sizeof(snd_pcm_direct_share_t),
|
||||
dmix->ipc_perm);
|
||||
if (dmix->shmid < 0) {
|
||||
if (errno == ENOENT)
|
||||
if (dmix->shmid < 0 && errno == ENOENT) {
|
||||
if ((dmix->shmid = shmget(dmix->ipc_key, sizeof(snd_pcm_direct_share_t),
|
||||
IPC_CREAT | IPC_EXCL | dmix->ipc_perm)) != -1)
|
||||
first_instance = 1;
|
||||
else if (errno == EEXIST)
|
||||
goto retryget;
|
||||
}
|
||||
err = -errno;
|
||||
if (dmix->shmid < 0) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue