summaryrefslogtreecommitdiff
path: root/doc/libs6lock
diff options
context:
space:
mode:
Diffstat (limited to 'doc/libs6lock')
-rw-r--r--doc/libs6lock/index.html256
-rw-r--r--doc/libs6lock/s6lockd-helper.html52
-rw-r--r--doc/libs6lock/s6lockd.html73
3 files changed, 0 insertions, 381 deletions
diff --git a/doc/libs6lock/index.html b/doc/libs6lock/index.html
deleted file mode 100644
index 7237823..0000000
--- a/doc/libs6lock/index.html
+++ /dev/null
@@ -1,256 +0,0 @@
-<html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <meta http-equiv="Content-Language" content="en" />
- <title>s6: the s6lock library interface</title>
- <meta name="Description" content="s6: the s6lock library interface" />
- <meta name="Keywords" content="s6 timed lock s6lock libs6lock library interface" />
- <!-- <link rel="stylesheet" type="text/css" href="http://skarnet.org/default.css" /> -->
- </head>
-<body>
-
-<p>
-<a href="../">s6</a><br />
-<a href="http://skarnet.org/software/">Software</a><br />
-<a href="http://skarnet.org/">skarnet.org</a>
-</p>
-
-<h1> The <tt>s6lock</tt> library interface </h1>
-
-<h2> General information </h2>
-
-<p>
- <tt>libs6lock</tt> is a C interface to timed locks. Unix natively provides
-locks, but the locking primitives are synchronous, so either they are
-unbounded in execution time or they require polling. libs6lock provides
-poll-free locks that can timeout during attempted acquisition.
-</p>
-
-<h2> Compiling </h2>
-
-<ul>
- <li> Make sure the s6 headers, as well as the skalibs headers,
-are visible in your header search path. </li>
- <li> Use <tt>#include &lt;s6/s6lock.h&gt;</tt> </li>
-</ul>
-
-<h2> Linking </h2>
-
-<ul>
- <li> Make sure the s6 libraries, as well as the skalibs libraries,
-are visible in your library search path. </li>
- <li> Link against <tt>-ls6</tt>, <tt>-lskarnet</tt>,
-<tt>`cat $sysdeps/socket.lib`</tt>, and
-<tt>`cat $sysdeps/tainnow.lib`</tt>,
-if <tt>$sysdeps</tt> is your skalibs installation's sysdeps directory. </li>
-</ul>
-
-<h2> Programming </h2>
-
-<ul>
- <li> Check the <tt>s6/s6lock.h</tt> header
-for the prototypes. The functions documented here are
-often simplified macros, for instance relying on the STAMP global variable
-to hold the current time. Fully reentrant functions with more control
-options are usually available. </li>
- <li> Given the nature of the s6lock library, it makes sense to use a
-<a href="http://skarnet.org/software/s6-networking/localservice.html">s6lockd service</a> concurrently
-accessed by several applications using such locks to gate shared
-resources. </li>
- <li> If you're not using a s6lockd service,
-make sure your application is not disturbed by children it doesn't
-know it has. Using nonblocking waits, ignoring pids you don't know, and
-using a
-<a href="http://skarnet.org/software/skalibs/libstddjb/selfpipe.html">self-pipe</a>
-if your application is built around an event loop, are good programming
-practices. </li>
-</ul>
-
-<h3> Starting and ending a session </h3>
-
-<pre>
-s6lock_t a = S6LOCK_ZERO ;
-tain_t deadline ;
-
-tain_now_g() ;
-tain_addsec_g(&amp;deadline, 2)
-
-char const *path = S6LOCK_IPCPATH ;
-s6lock_start_g(&amp;a, path, &amp;deadline) ;
-// char const *lockdir = "/tmp/lock" ;
-// s6lock_startf_g(&amp;a, lockdir, &amp;deadline) ;
-</pre>
-
-<p>
-<tt>s6lock_start_g</tt> starts a session by connecting to a s6lockd service
-listening on <em>path</em>. The working directory is set by the administrator
-of the service. <br />
-<tt>s6lock_startf_g</tt> starts a session with a s6lockd process as a child,
-using <em>lockdir</em> as its working directory.
-<br />
-<tt>a</tt> is a s6lock_t structure that must be declared in the stack and
-initialized to S6LOCK_ZERO.
-If the session initialization fails, the function returns 0 and errno is set;
-else the function returns 1.
-</p>
-<p>
-If the absolute time <tt>deadline</tt> is reached and the function
-has not returned yet, it immediately returns 0 with errno set to ETIMEDOUT.
-
-Only local interprocess communications are involved; unless your system is
-heavily overloaded, the function should return near-instantly. One or two
-seconds of delay between the current time and <tt>deadline</tt> should be
-enough: if the function takes more than that to return, then there is a
-problem with the underlying processes.
-</p>
-
-<p>
- You can have more than one session open in parallel, by declaring
-several distinct <tt>s6lock_t</tt> structures and calling
-<tt>s6lock_startf_g</tt> (or <tt>s6lock_start_g</tt>) more than once.
-However, one single session can handle
-virtually as many concurrent locks as your application needs, so
-opening several sessions is only useful if you need to acquire locks
-in various distinct lock directories.
-</p>
-
-<pre>
-s6lock_end(&amp;a) ;
-</pre>
-
-<p>
-<tt>s6lock_end</tt> frees all the resources used by the session. The
-<tt>a</tt> structure is then reusable for another session.
-</p>
-
-<h3> Acquiring and releasing locks </h3>
-
-<pre>
-uint16 id ;
-char const *file = "lockfile" ;
-tain_t limit ;
-tain_t deadline ;
-
-int r = s6lock_acquire_sh_g (&amp;a, &amp;id, file, &amp;limit, &amp;deadline) ;
-/* int r = s6lock_acquire_ex_g (&amp;a, &amp;id, file, &amp;limit, &amp;deadline) ; */
-r = s6lock_release_g(&amp;a, id, &amp;deadline) ;
-</pre>
-
-<p>
-<tt>s6lock_acquire_sh_g</tt> instructs the
-<a href="s6lockd.html">s6lockd daemon</a>, related to the open
-session represented by the <tt>a</tt> handle, to try and acquire a
-shared lock on the
-<em>file</em> file located under that daemon's working directory
-(typically <tt>/var/lock</tt>). <em>file</em> will be interpreted as
-relative to the daemon's working directory even if it starts with a
-slash; however, slashes in the middle of <em>file</em> are likely to
-result in an error.
-</p>
-
-<p>
-<em>limit</em> and <em>deadline</em> are two absolute dates.
-<em>deadline</em> is a deadline for the execution of the
-function: if by <em>deadline</em> the function has not returned,
-then it instantly returns 0 and sets errno to ETIMEDOUT. The
-function is normally near-instantaneous, so <em>deadline</em> can
-be very close in the future and serves only as a protection against
-malicious servers. <em>limit</em> is the acquisition deadline: if
-by <em>limit</em> the daemon still has not been able to acquire a lock
-on <em>file</em>, then it will report a timeout to the client.
-</p>
-
-<p>
-The function returns 1 in case of success, or 0 if an error occurs,
-with errno set to a suitable value. If it succeeds, then a 16-bit
-number is stored into *<em>id</em>; this number serves as an identifier
-for this lock.
-</p>
-
-<p>
-<tt>s6lock_acquire_ex_g</tt> works just like <tt>s6lock_acquire_sh_g</tt>,
-except that the daemon tries to acquire an exclusive lock.
-</p>
-
-<p>
-<tt>s6lock_release_g</tt> releases the lock identified by <em>id</em>.
-It normally returns 1. It can return 0 with errno set to a suitable
-value if it fails. <em>id</em> is not valid after the corresponding
-lock has been released. The function normally returns instantly, with
-<em>deadline</em> as a safeguard.
-</p>
-
-<h3> Asynchronously waiting for locks </h3>
-
-<p>
-<em> (from now on, the functions are listed with their prototypes instead
-of usage examples.) </em>
-</p>
-
-<pre>
-int s6lock_fd (s6lock_t const *a)
-</pre>
-
-<p>
- Returns a file descriptor to select on for reading. Do not
-<tt>read()</tt> it though.
-</p>
-
-<pre>
-int s6lock_update (s6lock_t *a)
-</pre>
-
-<p>
- Call this function whenever the fd checks readability: it will
-update <em>a</em>'s internal structures with information from the
-<a href="s6lockd.html">s6lockd</a> daemon. It returns -1 if an error
-occurs; in case of success, it returns the number of identifiers for
-which something happened.
-</p>
-
-<p>
- When <tt>s6lock_update</tt> returns,
-<tt>genalloc_s(uint16, &amp;a-&gt;list)</tt> points to an array of
-<tt>genalloc_len(uint16, &amp;a-&gt;list)</tt> 16-bit unsigned
-integers. Those integers are ids waiting to be passed to
-<tt>s6lock_check</tt>.
-</p>
-
-<pre>
-int s6lock_check (s6lock_t *a, uint16 id, char *what)
-</pre>
-
-<p>
- Checks whether the lock identified by <em>id</em> has
-been acquired. Use after a call to <tt>s6lock_update()</tt>.
-</p>
-
-<ul>
- <li> If an error occurred, returns -1 and sets errno. The error
-number may have been transmitted from
-<a href="s6lockd.html">s6lockd</a>. </li>
- <li> If the lock has not been acquired yet, returns 0. </li>
- <li> If the lock has been acquired, returns 1. </li>
-</ul>
-
-<h3> Synchronously waiting for locks </h3>
-
-<p>
-<code> int s6lock_wait_or_g (s6lock_t *a, uint16 const *idlist, unsigned int n, tain_t const *deadline) </code> <br />
-Synchronously waits for <em>one</em> of the locks represented by the array pointed to
-by <em>idlist</em> of length <em>n</em> to be acquired. Returns -1 if it fails,
-or a nonnegative number on success, which is the index in <em>idlist</em> of the
-acquired lock's id. If no result has been obtained by <em>deadline</em>, the
-function returns -1 ETIMEDOUT.
-</p>
-
-<p>
-<code> int s6lock_wait_and_g (s6lock_t *a, uint16 const *idlist, unsigned int n, tain_t const *deadline) </code> <br />
-Synchronously waits for <em>all</em> of the locks represented by the array pointed to
-by <em>idlist</em> of length <em>n</em> to be acquired. Returns -1 if it fails and
-0 if it succeeds. If no result has been obtained by <em>deadline</em>, the
-function returns -1 ETIMEDOUT.
-</p>
-
-</body>
-</html>
diff --git a/doc/libs6lock/s6lockd-helper.html b/doc/libs6lock/s6lockd-helper.html
deleted file mode 100644
index 839dce4..0000000
--- a/doc/libs6lock/s6lockd-helper.html
+++ /dev/null
@@ -1,52 +0,0 @@
-<html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <meta http-equiv="Content-Language" content="en" />
- <title>s6: the s6lockd-helper internal program</title>
- <meta name="Description" content="s6: the s6lockd-helper internal program" />
- <meta name="Keywords" content="s6 s6lockd-helper lockd asynchronous timed lock daemon helper" />
- <!-- <link rel="stylesheet" type="text/css" href="http://skarnet.org/default.css" /> -->
- </head>
-<body>
-
-<a href="index.html">libs6lock</a><br />
-<a href="../">s6</a><br />
-<a href="http://skarnet.org/software/">Software</a><br />
-<a href="http://skarnet.org/">skarnet.org</a><p />
-
-<h1> The <tt>s6lockd-helper</tt> program </h1>
-
-<p>
-<tt>s6lockd-helper</tt> is a helper program for the s6lock daemon.
-It just acquires a lock and holds it until it is killed or told to
-exit by its parent daemon.
-</p>
-
-<h2> Interface </h2>
-
-<p>
- s6lockd-helper is not meant to be invoked directly by the user:
-it will be spawned by the
-<a href="s6lockd.html">s6lockd</a> program.
-</p>
-
-<h2> Notes </h2>
-
-<ul>
- <li> s6lockd-helper blocks on lock acquisition until it succeeds. It then
-notifies its parent. It exits when its parent tells him to (i.e. when the
-client asks for lock release). During the lock acquisition phase, it can
-be killed if its parent detects a timeout. </li>
- <li> One s6lockd-helper process per lock is the only way (apart from
-threads) to implement timed lock acquisition. This can lead to a lot of
-s6lockd-helper processes, but this is not a problem:
- <ul>
- <li> Processes are not a scarce resource. Today's schedulers work in O(1),
-i.e. a sleeping process takes no scheduling time at all. </li>
- <li> s6lockd-helper is extremely tiny. Every instance should use up at
-most one or two pages of non-sharable memory. </li>
- </ul> </li>
-</ul>
-
-</body>
-</html>
diff --git a/doc/libs6lock/s6lockd.html b/doc/libs6lock/s6lockd.html
deleted file mode 100644
index 726d2f8..0000000
--- a/doc/libs6lock/s6lockd.html
+++ /dev/null
@@ -1,73 +0,0 @@
-<html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <meta http-equiv="Content-Language" content="en" />
- <title>s6: the s6lockd internal program</title>
- <meta name="Description" content="s6: the s6lockd internal program" />
- <meta name="Keywords" content="s6 s6lockd lockd asynchronous timed lock daemon" />
- <!-- <link rel="stylesheet" type="text/css" href="http://skarnet.org/default.css" /> -->
- </head>
-<body>
-
-<a href="index.html">libs6lock</a><br />
-<a href="../">s6</a><br />
-<a href="http://skarnet.org/software/">Software</a><br />
-<a href="http://skarnet.org/">skarnet.org</a><p />
-
-<h1> The <tt>s6lockd</tt> program </h1>
-
-<p>
-<tt>s6lockd</tt> is the s6lock daemon. It is a program that manages
-a set of lock files in a given directory, and associated timeouts.
-</p>
-
-<h2> Interface </h2>
-
-<p>
- s6lockd does not fork, does not background itself automatically,
-and does not use syslog. It is not meant to be run directly by the
-user: it will be spawned by the
-<a href="index.html">s6lock client library</a>.
-</p>
-
-<p>
- There are 2 ways to use s6lockd:
-</p>
-
-<ol>
- <li> Use the <tt>s6lock_startf()</tt> library call.
-A <tt>s6lockd</tt> child will then be spawned from your
-calling process, and automatically reaped when you call
-<tt>s6lock_end()</tt>. It requires care with applications that
-trap SIGCHLD. It also requires care with lock file permissions:
-a s6lockd instance might not be able
-to open a lock file created by a former instance run by another
-client with different permissions. </li>
- <li> Use the <tt>s6lock_start()</tt> library call, together with a
-<a href="http://skarnet.org/software/s6-networking/localservice.html">s6lockd service</a>.
-For once, <em>this is the recommended setup</em>: s6lockd creates empty
-lock files, and having all s6lockd instances run under the same user
-simplifies permissions management considerably. </li>
- </li>
-</ol>
-
-<p>
-When run as a service, s6lockd has no "standalone" mode: it is
-designed to work with a Unix
-domain superserver, like
-<a href="http://skarnet.org/software/s6-networking/s6-ipcserver.html">s6-ipcserver</a>.
-s6lockd follows the <a href="http://cr.yp.to/proto/ucspi.txt">UCSPI</a>
-interface, it can be directly executed from the superserver.
-</p>
-
-<h2> Notes </h2>
-
-<ul>
- <li> Unix does not natively provide a way to stop blocking on a lock
-acquisition after a timeout. To emulate such behaviour, s6lockd actually
-spawns a <a href="s6lockd-helper.html">s6lockd-helper</a> child per
-requested lock. </li>
-</ul>
-
-</body>
-</html>