File 0023-pcm-Avoid-lock-for-snd_pcm_nonblock.patch of Package alsa.openSUSE_Leap_42.2_Update

From b5a2c06f6c5d69fc71ef648af95a044ee1dc25d0 Mon Sep 17 00:00:00 2001
From: Takashi Iwai <tiwai@suse.de>
Date: Thu, 9 Feb 2017 17:23:22 +0100
Subject: [PATCH 23/43] pcm: Avoid lock for snd_pcm_nonblock()

snd_pcm_nonblock() is called as snd_pcm_abort().  Since
snd_pcm_abort() is called often from a signal handler to clean things
up (e.g. aplay does it), we may face a deadlock if the signal is
raised during the locked operation.

There can be some way to check the deadlock state, but they would cost
much.  Since the race condition of snd_pcm_nonblock() is quite small,
let's just drop the locking inside snd_pcm_nonblock() as a
workaround.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 src/pcm/pcm.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

--- a/src/pcm/pcm.c
+++ b/src/pcm/pcm.c
@@ -759,7 +759,10 @@ int snd_pcm_nonblock(snd_pcm_t *pcm, int
 	int err = 0;
 
 	assert(pcm);
-	__snd_pcm_lock(pcm); /* forced lock due to pcm field change */
+	/* FIXME: __snd_pcm_lock() call below is commented out because of the
+	 * the possible deadlock in signal handler calling snd_pcm_abort()
+	 */
+	/* __snd_pcm_lock(pcm); */ /* forced lock due to pcm field change */
 	if ((err = pcm->ops->nonblock(pcm->op_arg, nonblock)) < 0)
 		goto unlock;
 	if (nonblock == 2) {
@@ -775,7 +778,7 @@ int snd_pcm_nonblock(snd_pcm_t *pcm, int
 			pcm->mode &= ~SND_PCM_NONBLOCK;
 	}
  unlock:
-	__snd_pcm_unlock(pcm);
+	/* __snd_pcm_unlock(pcm); */ /* FIXME: see above */
 	return err;
 }
 
openSUSE Build Service is sponsored by