Accepting request 855584 from home:tiwai:branches:multimedia:libs

- Fix alsactl restore behavior during locking (boo#1179904):
  0010-alsactl-Fix-double-decrease-of-lock-timeout.patch
  0011-alsactl-Fix-race-at-creating-a-lock-file.patch
- Remove unnecessary condition for alsa-restore.service
  0012-alsactl-Remove-asound.state-file-check-from-alsa-res.patch
- Fix dependency in sound-extra.service

OBS-URL: https://build.opensuse.org/request/show/855584
OBS-URL: https://build.opensuse.org/package/show/multimedia:libs/alsa-utils?expand=0&rev=186
This commit is contained in:
Takashi Iwai 2020-12-13 16:36:36 +00:00 committed by Git OBS Bridge
parent 4d467c260f
commit e431020b1e
6 changed files with 126 additions and 1 deletions

View File

@ -0,0 +1,29 @@
From 878e1a7c0f03233530e7675ae015aced069c971d Mon Sep 17 00:00:00 2001
From: Takashi Iwai <tiwai@suse.de>
Date: Fri, 11 Dec 2020 23:41:59 +0100
Subject: [PATCH] alsactl: Fix double decrease of lock timeout
The state_lock() has a loop to wait for the lock file creation, and
the timeout value gets decremented twice mistakenly, which leads to a
half timeout (5 seconds) than expected 10 seconds. Fix it.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
alsactl/lock.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/alsactl/lock.c b/alsactl/lock.c
index 4a485392b3bd..05f6e4d2a102 100644
--- a/alsactl/lock.c
+++ b/alsactl/lock.c
@@ -63,7 +63,6 @@ static int state_lock_(const char *file, int lock, int timeout, int _fd)
if (fd < 0) {
if (errno == EBUSY || errno == EAGAIN) {
sleep(1);
- timeout--;
} else {
err = -errno;
goto out;
--
2.26.2

View File

@ -0,0 +1,47 @@
From c53f7cd03881092d5a61505d23ab8f920b7faf12 Mon Sep 17 00:00:00 2001
From: Takashi Iwai <tiwai@suse.de>
Date: Fri, 11 Dec 2020 23:46:23 +0100
Subject: [PATCH] alsactl: Fix race at creating a lock file
A race at creating a lock file in state_lock() was discovered
recently: namely, between the first open(O_RDWR) and the second
open(O_RDWR|O_CREAT|O_EXCL) calls, another alsactl invocation may
already create a lock file, then the second open() will return EEXIST,
which isn't handled properly and treated as a fatal error.
In this patch, we check EEXIST case and try again open() with O_RDWR.
This must succeed usually, and if it fails, handle finally as the
fatal error.
BugLink: https://bugzilla.opensuse.org/show_bug.cgi?id=1179904
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
alsactl/lock.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/alsactl/lock.c b/alsactl/lock.c
index 05f6e4d2a102..5b4746231996 100644
--- a/alsactl/lock.c
+++ b/alsactl/lock.c
@@ -63,10 +63,15 @@ static int state_lock_(const char *file, int lock, int timeout, int _fd)
if (fd < 0) {
if (errno == EBUSY || errno == EAGAIN) {
sleep(1);
- } else {
- err = -errno;
- goto out;
+ continue;
}
+ if (errno == EEXIST) {
+ fd = open(nfile, O_RDWR);
+ if (fd >= 0)
+ break;
+ }
+ err = -errno;
+ goto out;
}
}
}
--
2.26.2

View File

@ -0,0 +1,33 @@
From 12487b40b6e7230a003eb6e4333ee820d8578592 Mon Sep 17 00:00:00 2001
From: Takashi Iwai <tiwai@suse.de>
Date: Fri, 11 Dec 2020 23:55:34 +0100
Subject: [PATCH ] alsactl: Remove asound.state file check from alsa-restore.service again
We added the check of asound.state file presence some time ago to
assure that alsactl gets called only if the state file is already
present. Since then, the situation has changed significantly:
e.g. now alsactl does initialize if the state file isn't present, and
the same alsa-restore.service is used to save the state. This means
that we should start this service no matter the state file exists at
the boot time or not. So, revert the old change again.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
alsactl/alsa-restore.service.in | 1 -
1 file changed, 1 deletion(-)
diff --git a/alsactl/alsa-restore.service.in b/alsactl/alsa-restore.service.in
index a84c2e842444..80fd5fd48203 100644
--- a/alsactl/alsa-restore.service.in
+++ b/alsactl/alsa-restore.service.in
@@ -7,7 +7,6 @@
Description=Save/Restore Sound Card State
ConditionPathExists=!@daemonswitch@
ConditionPathExistsGlob=/dev/snd/control*
-ConditionPathExists=@asoundrcfile@
[Service]
Type=oneshot
--
2.26.2

View File

@ -1,3 +1,13 @@
-------------------------------------------------------------------
Fri Dec 11 23:52:24 CET 2020 - tiwai@suse.de
- Fix alsactl restore behavior during locking (boo#1179904):
0010-alsactl-Fix-double-decrease-of-lock-timeout.patch
0011-alsactl-Fix-race-at-creating-a-lock-file.patch
- Remove unnecessary condition for alsa-restore.service
0012-alsactl-Remove-asound.state-file-check-from-alsa-res.patch
- Fix dependency in sound-extra.service
-------------------------------------------------------------------
Wed Oct 21 13:01:26 CEST 2020 - tiwai@suse.de

View File

@ -29,6 +29,9 @@ Source: ftp://ftp.alsa-project.org/pub/utils/alsa-utils-%{version}.tar.b
Source1: 01beep.conf
Source2: sound-extra.service
Source5: load-sound-modules.sh
Patch10: 0010-alsactl-Fix-double-decrease-of-lock-timeout.patch
Patch11: 0011-alsactl-Fix-race-at-creating-a-lock-file.patch
Patch12: 0012-alsactl-Remove-asound.state-file-check-from-alsa-res.patch
Patch101: alsa-utils-configure-version-revert.patch
BuildRequires: alsa-devel
%ifarch %ix86 x86_64 %arm aarch64 ppc64le riscv64
@ -71,6 +74,9 @@ and test audio before and after PM state changes.
%prep
%setup -q
%patch10 -p1
%patch11 -p1
%patch12 -p1
%if 0%{?do_autoreconf}
%patch101 -p1
# fix stupid automake's automatic action

View File

@ -1,6 +1,6 @@
[Unit]
Description=Load extra kernel modules for sound stuff
After=alsasound.service
After=alsa-restore.service
ConditionPathExists=/proc/asound
[Service]