diff --git a/0010-alsactl-Fix-double-decrease-of-lock-timeout.patch b/0010-alsactl-Fix-double-decrease-of-lock-timeout.patch new file mode 100644 index 0000000..eed6f6e --- /dev/null +++ b/0010-alsactl-Fix-double-decrease-of-lock-timeout.patch @@ -0,0 +1,29 @@ +From 878e1a7c0f03233530e7675ae015aced069c971d Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +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 +--- + 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 + diff --git a/0011-alsactl-Fix-race-at-creating-a-lock-file.patch b/0011-alsactl-Fix-race-at-creating-a-lock-file.patch new file mode 100644 index 0000000..edc2748 --- /dev/null +++ b/0011-alsactl-Fix-race-at-creating-a-lock-file.patch @@ -0,0 +1,47 @@ +From c53f7cd03881092d5a61505d23ab8f920b7faf12 Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +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 +--- + 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 + diff --git a/0012-alsactl-Remove-asound.state-file-check-from-alsa-res.patch b/0012-alsactl-Remove-asound.state-file-check-from-alsa-res.patch new file mode 100644 index 0000000..635365c --- /dev/null +++ b/0012-alsactl-Remove-asound.state-file-check-from-alsa-res.patch @@ -0,0 +1,33 @@ +From 12487b40b6e7230a003eb6e4333ee820d8578592 Mon Sep 17 00:00:00 2001 +From: Takashi Iwai +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 +--- + 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 + diff --git a/alsa-utils.changes b/alsa-utils.changes index 318b3e0..3661b58 100644 --- a/alsa-utils.changes +++ b/alsa-utils.changes @@ -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 diff --git a/alsa-utils.spec b/alsa-utils.spec index 30ce650..0852d90 100644 --- a/alsa-utils.spec +++ b/alsa-utils.spec @@ -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 diff --git a/sound-extra.service b/sound-extra.service index 89c1744..8b5299f 100644 --- a/sound-extra.service +++ b/sound-extra.service @@ -1,6 +1,6 @@ [Unit] Description=Load extra kernel modules for sound stuff -After=alsasound.service +After=alsa-restore.service ConditionPathExists=/proc/asound [Service]