summaryrefslogtreecommitdiff
path: root/doc/libstddjb
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 /doc/libstddjb
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 'doc/libstddjb')
-rw-r--r--doc/libstddjb/djbunix.html45
1 files changed, 13 insertions, 32 deletions
diff --git a/doc/libstddjb/djbunix.html b/doc/libstddjb/djbunix.html
index e70fe4f..54aaf50 100644
--- a/doc/libstddjb/djbunix.html
+++ b/doc/libstddjb/djbunix.html
@@ -202,45 +202,26 @@ with errno saved, used essentially to isolate application code from
</p>
<p>
-<code> int lock_ex (int fd) </code> <br />
-Gets an exclusive advisory lock on <em>fd</em>. <em>fd</em> must point to
-a regular file, open for writing. Blocks until the lock can be obtained.
-Returns 0 if it succeeds, or -1 (and sets errno) if it fails.
-</p>
-
-<p>
-<code> int lock_exnb (int fd) </code> <br />
-Gets an exclusive advisory lock on <em>fd</em>. <em>fd</em> must point to
-a regular file, open for writing.
-Returns 0 if it succeeds, or -1 (and sets errno) if it fails. If the lock
-is held and the function would block, it immediately returns with -1 EWOULDBLOCK.
-</p>
-
-<p>
-<code> int lock_sh (int fd) </code> <br />
-Gets a shared advisory lock on <em>fd</em>. <em>fd</em> must point to
-a regular file, open for reading. Blocks until the lock can be obtained.
-Returns 0 if it succeeds, or -1 (and sets errno) if it fails.
-</p>
-
-<p>
-<code> int lock_shnb (int fd) </code> <br />
-Gets a shared advisory lock on <em>fd</em>. <em>fd</em> must point to
-a regular file, open for reading.
-Returns 0 if it succeeds, or -1 (and sets errno) if it fails. If the lock
-is held and the function would block, it immediately returns with -1 EWOULDBLOCK.
+<code> int fd_lock (int fd, int w, int nb) </code> <br />
+Gets an advisory lock on <em>fd</em>: shared if <em>w</em> is
+zero, exclusive otherwise. <em>fd</em> must point to
+a regular file, open for writing or reading depending on whether
+you want an exclusive lock or not. If <em>nb</em> is zero, the
+function blocks until the lock can be obtained; otherwise it
+returns 0 immediately. On success, the function returns 1 ; it
+returns 0 if it cannot take the lock, or -1 (and sets errno) if
+an error occurs.
</p>
<p>
-<code> int lock_un (int fd) </code> <br />
+<code> void fd_unlock (int fd) </code> <br />
Releases a previously held lock on <em>fd</em>.
-Returns 0 if it succeeds, or -1 (and sets errno) if it fails.
</p>
<p>
-<code> void lock_unx (int fd) </code> <br />
-Like <tt>lock_un</tt>, but without a return code and without
-modifying errno.
+<code> int fd_islocked (int fd) </code> <br />
+Returns 1 if a lock is currently held on fd, 0 otherwise.
+Returns -1 (and sets errno) if an error occurs.
</p>
<p>