mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-04 13:29:59 -05:00
add proper locking when accessing the file volume.table
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@905 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
parent
1267285257
commit
e0bf4a32f3
1 changed files with 12 additions and 3 deletions
|
|
@ -39,6 +39,7 @@
|
||||||
#include <polypcore/core-subscribe.h>
|
#include <polypcore/core-subscribe.h>
|
||||||
#include <polypcore/xmalloc.h>
|
#include <polypcore/xmalloc.h>
|
||||||
#include <polypcore/sink-input.h>
|
#include <polypcore/sink-input.h>
|
||||||
|
#include <polypcore/util.h>
|
||||||
#include <polyp/volume.h>
|
#include <polyp/volume.h>
|
||||||
|
|
||||||
#include "module-volume-restore-symdef.h"
|
#include "module-volume-restore-symdef.h"
|
||||||
|
|
@ -127,6 +128,8 @@ static int load_rules(struct userdata *u) {
|
||||||
goto finish;
|
goto finish;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pa_lock_fd(fileno(f), 1);
|
||||||
|
|
||||||
while (!feof(f)) {
|
while (!feof(f)) {
|
||||||
struct rule *rule;
|
struct rule *rule;
|
||||||
pa_cvolume v;
|
pa_cvolume v;
|
||||||
|
|
@ -175,8 +178,10 @@ static int load_rules(struct userdata *u) {
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
finish:
|
finish:
|
||||||
if (f)
|
if (f) {
|
||||||
|
pa_lock_fd(fileno(f), 0);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
@ -196,6 +201,8 @@ static int save_rules(struct userdata *u) {
|
||||||
goto finish;
|
goto finish;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pa_lock_fd(fileno(f), 1);
|
||||||
|
|
||||||
while ((rule = pa_hashmap_iterate(u->hashmap, &state, NULL))) {
|
while ((rule = pa_hashmap_iterate(u->hashmap, &state, NULL))) {
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
|
|
@ -210,8 +217,10 @@ static int save_rules(struct userdata *u) {
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
finish:
|
finish:
|
||||||
if (f)
|
if (f) {
|
||||||
|
pa_lock_fd(fileno(f), 0);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue