add proper locking when accessing the file match.table
authorLennart Poettering <lennart@poettering.net>
Wed, 17 May 2006 15:21:34 +0000 (15:21 +0000)
committerLennart Poettering <lennart@poettering.net>
Wed, 17 May 2006 15:21:34 +0000 (15:21 +0000)
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@906 fefdeb5f-60dc-0310-8127-8f9354f1896f

src/modules/module-match.c

index f6316b9..9e3edb7 100644 (file)
@@ -39,6 +39,7 @@
 #include <polypcore/core-subscribe.h>
 #include <polypcore/xmalloc.h>
 #include <polypcore/sink-input.h>
+#include <polypcore/util.h>
 
 #include "module-match-symdef.h"
 
@@ -88,6 +89,8 @@ static int load_rules(struct userdata *u, const char *filename) {
         goto finish;
     }
 
+    pa_lock_fd(fileno(f), 1);
+    
     while (!feof(f)) {
         char *d, *v;
         pa_volume_t volume;
@@ -146,8 +149,10 @@ static int load_rules(struct userdata *u, const char *filename) {
     ret = 0;
     
 finish:
-    if (f)
+    if (f) {
+        pa_lock_fd(fileno(f), 0);
         fclose(f);
+    }
 
     if (fn)
         pa_xfree(fn);