Bug#43651: ACCEPTED] mailbox locking
I am about to include this amendment in policy. However, I am stuck
with the wording, as you say the following.
Questions: What version number should be used in footnote 2?
What do we do with the reference implementation?
> So I think we should change the above paragraph to something which
> explicitly says, how locking has to be implemented:
>
> All Debian MUAs, MTAs, MDAs and other mailbox accessing programs
> (like IMAP daemons) have to lock the mailbox in a NFS-safe way.
> This means that fcntl() locking has to be combined with dot
> locking. To avoid dead locks, a program has to use fcntl() first
> and dot locking after this or alternatively implement the two
> locking methods in a non blocking way[1]. Using the functions
> `maillock' and `mailunlock' provided by the `liblockfile*'[2]
> packages is the recommended way to realize this.
>
> Footnotes:
> [1] If it is not possible to establish both locks, the system
> shouldn't wait for the second lock to be established, but
> remove the first lock, wait a (random) time, and start over
> locking again.
> [2] liblockfile version >= .... (fill in a version number here,
> which implements the above noted non blocking mechanism
> without blocking).
>
>
> Thomas Roessler <roessler@guug.de> posted a skeleton of maillock() to
> debian-devel, maybe we should place this somewhere in the policy or in
> /usr/[share/]doc/debian-policy/ or take this as a basis for a new
> version of liblockfile:
>
> int do_lock (const char *path, int fd, int retries)
> {
> int i;
> int rv;
>
> for (i = 0; i < retries; i++)
> {
> if ((rv = do_fcntl_lock (fd)) == -1 && errno != EAGAIN)
> return -1;
> else if (rv == 0)
> {
> if (do_dotlock (path) == 0)
> return 0;
> do_fcntl_unlock (fd);
> }
> sleep (rand() % 10);
> }
> return -1;
> }
Julian
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Julian Gilbey, Dept of Maths, QMW, Univ. of London. J.D.Gilbey@qmw.ac.uk
Debian GNU/Linux Developer, see http://www.debian.org/~jdg
Reply to: