From 4f92a29b943e5d7906b884009758627bc7c3376b Mon Sep 17 00:00:00 2001 From: Duncan Overbruck Date: Mon, 1 Mar 2021 00:48:20 +0100 Subject: fq: use shared locks to avoid holding exclusive locks for a split second --- fq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fq.c b/fq.c index ebfe6f8..a61240f 100644 --- a/fq.c +++ b/fq.c @@ -43,7 +43,7 @@ char buf[8192]; static int islocked(int fd) { - if (flock(fd, LOCK_EX | LOCK_NB) == -1) { + if (flock(fd, LOCK_SH | LOCK_NB) == -1) { return (errno == EWOULDBLOCK); } else { flock(fd, LOCK_UN); @@ -207,7 +207,7 @@ main(int argc, char *argv[]) if (nflag && islocked(fd)) break; - if (flock(fd, LOCK_EX | LOCK_NB) == -1 && + if (flock(fd, LOCK_SH | LOCK_NB) == -1 && errno == EWOULDBLOCK) { #if defined(USE_INOTIFY) /* any inotify event is good */ -- cgit 1.4.1