From 84586ab9fc1f3540f7182c822d779d85f6ffafa7 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Thu, 10 Dec 2020 19:55:35 +0000 Subject: You want shared locks, Sherlock --- src/libs6rc/s6rc_lock.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/libs6rc/s6rc_lock.c b/src/libs6rc/s6rc_lock.c index e879fcc..9daaa34 100644 --- a/src/libs6rc/s6rc_lock.c +++ b/src/libs6rc/s6rc_lock.c @@ -2,6 +2,7 @@ #include #include +#include #include @@ -18,9 +19,8 @@ int s6rc_lock (char const *live, int lwhat, int *llfd, char const *compiled, int char lfn[llen + 6] ; memcpy(lfn, live, llen) ; memcpy(lfn + llen, "/lock", 6) ; - lfd = open_create(lfn) ; + lfd = open(lfn, O_RDWR | O_CREAT | O_TRUNC | O_NONBLOCK | O_CLOEXEC, 0644) ; if (lfd < 0) return 0 ; - if (coe(lfd) < 0) goto lerr ; r = fd_lock(lfd, lwhat > 1, !blocking) ; if (!r) errno = EBUSY ; if (r < 1) goto lerr ; @@ -32,15 +32,13 @@ int s6rc_lock (char const *live, int lwhat, int *llfd, char const *compiled, int char cfn[clen + 6] ; memcpy(cfn, compiled, clen) ; memcpy(cfn + clen, "/lock", 6) ; - cfd = open_create(cfn) ; + cfd = open(cfn, O_RDWR | O_CREAT | O_TRUNC | O_NONBLOCK | O_CLOEXEC, 0644) ; if (cfd < 0) if (cwhat > 1 || errno != EROFS) goto lerr ; else cfd = -errno ; else { - int r ; - if (coe(cfd) < 0) goto cerr ; - r = fd_lock(cfd, cwhat > 1, !blocking) ; + int r = fd_lock(cfd, cwhat > 1, !blocking) ; if (!r) errno = EBUSY ; if (r < 1) goto cerr ; } -- cgit v1.2.3