summaryrefslogtreecommitdiff
path: root/src/libstddjb/lock_un.c
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2020-11-29 21:02:32 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2020-11-29 21:02:32 +0000
commit90b819c6d832046840018ff08b9bc5d0e3b69c37 (patch)
treeefea05788cc982395ee114474d84096e7fc70862 /src/libstddjb/lock_un.c
parente6c5c984461dc4cec0ef2d68524d6bd457e23853 (diff)
downloadskalibs-90b819c6d832046840018ff08b9bc5d0e3b69c37.tar.xz
Revamp lock primitives; prepare for 2.10.0.0 instead of 2.9.4.0
flock() doesn't have a way to test for a lock without taking it. lockf() doesn't have shared locks. The only way to have both is fcntl(). So I rewrote all the locking stuff around fcntl(), and used the opportunity to change the interface. The point of changing the interface is to stop having to bother with the old one, so to hell with compatibility, let's just do a major bump.
Diffstat (limited to 'src/libstddjb/lock_un.c')
-rw-r--r--src/libstddjb/lock_un.c34
1 files changed, 0 insertions, 34 deletions
diff --git a/src/libstddjb/lock_un.c b/src/libstddjb/lock_un.c
deleted file mode 100644
index a029a7c..0000000
--- a/src/libstddjb/lock_un.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/* ISC license. */
-
-#include <skalibs/sysdeps.h>
-
-#ifdef SKALIBS_HASFLOCK
-
-#include <skalibs/nonposix.h>
-#include <errno.h>
-#include <sys/file.h>
-#include <skalibs/djbunix.h>
-
-int lock_un (int fd)
-{
- int r ;
- do r = flock(fd, LOCK_UN) ;
- while ((r == -1) && (errno == EINTR)) ;
- return r ;
-}
-
-#else
-
-#include <unistd.h>
-#include <errno.h>
-#include <skalibs/djbunix.h>
-
-int lock_un (int fd)
-{
- int r ;
- do r = lockf(fd, F_ULOCK, 0) ;
- while ((r == -1) && (errno == EINTR)) ;
- return r ;
-}
-
-#endif