Mbox Locking
============

The only standard way to lock a mbox is using a method called "dotlock". This
means that a file named '<mailbox-name>.lock' is created into same directory as
the mailbox being locked. This works pretty well when mbox is locked for
writing, but for reading it's very inefficient. That's why other locking
methods have been used.

*It's important that all software that's reading or writing to mboxes use the
same locking settings.* If they use only different methods, they might
read/write to mbox while another process is modifying it, and seeing corrupted
mails. If they use same methods but in different order, they can both end up in
a deadlock.

If you want to know more details about the locking, see <the mbox format page>
[MailboxFormat.mbox.txt].

For Dovecot you can configure the locking using 'mbox_read_locks' and
'mbox_write_locks' settings. The defaults are:

---%<-------------------------------------------------------------------------
mbox_read_locks = fcntl
mbox_write_locks = dotlock fcntl
---%<-------------------------------------------------------------------------

Here's a list of how to find out the locking settings for other software:

Procmail
--------

---%<-------------------------------------------------------------------------
# procmail -v 2>&1|grep Locking
Locking strategies:     dotlocking, fcntl()
---%<-------------------------------------------------------------------------

Postfix
-------

Postfix has two different ways to deliver to mboxes. One is "mailbox" transport
and another one is "virtual" transport.

---%<-------------------------------------------------------------------------
# postconf -d|grep mailbox_delivery_lock
mailbox_delivery_lock = fcntl, dotlock
# postconf -d|grep virtual_mailbox_lock
virtual_mailbox_lock = fcntl
---%<-------------------------------------------------------------------------

In above case if you used "mailbox" transport, you'd have to change Dovecot's
configuration to 'mbox_write_locks = fcntl dotlock' or vice versa for Postfix.

If you used "virtual" transport, it doesn't really matter if the "dotlock" is
missing, since the "fcntl" is common with Dovecot and Postfix.

mutt
----

---%<-------------------------------------------------------------------------
mutt -v|grep -i lock
---%<-------------------------------------------------------------------------

Debian
------

Debian's policy specifies that all software should use "fcntl and then dotlock"
locking, but this probably applies only to most commonly used software.

(This file was created from the wiki on 2007-04-13 14:32)
