[PATCH] alsactl: Skip restore during the lock
Jaroslav Kysela
perex at perex.cz
Fri Dec 11 17:45:45 CET 2020
Dne 11. 12. 20 v 9:38 Takashi Iwai napsal(a):
> Currently alsactl-restore tries to initialize the device when an error
> is found for restore action. But this isn't the right behavior in the
> case where the lock is held; it implies that another alsactl is
> running concurrently, hence you shouldn't initialize the card at the
> same time. The situation is found easily when two alsactls get
> started by both udev and systemd (note that those two invocations are
> the designed behavior, see /usr/lib/udev/rules.d/78-sound-cards.rules
> for details).
>
> This patch changes load_state() not to handle the initialization if
> the locking fails.
The operation should serialize in this case (there's limit of 10 seconds which
should be enough to finish the initialization). The state_lock() function
should return -EBUSY when the file is locked (and I'm fine to change the
behaviour from 'init' to 'skip' for this lock state).
It seems that -EEXIST is returned when the lock file exists, but the
open(file, O_CREAT|O_EXCL, 0644) caller has not enough priviledges to access
this file when another user owns the file.
But alsactl from /lib/udev/rules.d/90-alsa-restore.rules and
/lib/systemd/system/alsa-restore.service should be run as root, right?
Jaroslav
--
Jaroslav Kysela <perex at perex.cz>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.
More information about the Alsa-devel
mailing list