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
This commit is contained in:
Lennart Poettering 2004-09-27 15:40:18 +00:00
parent 949014e154
commit 35148d8c05
4 changed files with 92 additions and 52 deletions

View file

@ -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;
}