summaryrefslogtreecommitdiffstats
path: root/polyp/util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2004-09-27 15:40:18 +0000
committerLennart Poettering <lennart@poettering.net>2004-09-27 15:40:18 +0000
commit35148d8c0565d9b7faafe423367c4bd750461533 (patch)
treeadd5dd975d6d3bdb3114e255f93e7bf8b5806b55 /polyp/util.c
parent949014e154dec912e080335630818ed016b45394 (diff)
add POSIX locking to authkey.c
fix esound protocol cpu consumption when finishing a stream git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@242 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'polyp/util.c')
-rw-r--r--polyp/util.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/polyp/util.c b/polyp/util.c
index 6be6ffe4..166a9a45 100644
--- a/polyp/util.c
+++ b/polyp/util.c
@@ -501,3 +501,20 @@ finish:
pa_xfree(gids);
return r;
}
+
+int pa_lock_file(int fd, int b) {
+
+ struct flock flock;
+
+ flock.l_type = b ? F_WRLCK : F_UNLCK;
+ flock.l_whence = SEEK_SET;
+ flock.l_start = 0;
+ flock.l_len = 0;
+
+ if (fcntl(fd, F_SETLKW, &flock) < 0) {
+ pa_log(__FILE__": %slock failed: %s\n", !b ? "un" : "", strerror(errno));
+ return -1;
+ }
+
+ return 0;
+}