bug-mailutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: The sad state of locking -> it almost works


From: xystrus
Subject: Re: The sad state of locking -> it almost works
Date: Thu, 11 Apr 2002 15:53:38 -0400
User-agent: Mutt/1.3.27i

On Thu, Apr 11, 2002 at 01:06:52PM +0300, Sergey Poznyakoff wrote:
> This is possible, but consider this:
> 
>  1. Default Linux /bin/mail uses flock to lock mailbox before writing
>     to it.
>  2. Widely-used (on GNU/Linux at least) mail.local uses both dot-lock
>     and kernel-level locking via flock.

This also is what the UW-IMAP documentation suggests, except that
they recommend using fcntl() locking instead of flock.  The rationale
seems sound enough to me.  

Sam writes in the previous message in the thread that you can't switch
from a dotlock to a kernel lock and expect it to work.  I think it
makes sense it wouldn't; I'm not sure why it would make sense to
switch lock types in the middle of some operation.

The UW-IMAP documentation talks about locking at length, and you can
read what they have to say here:

  http://www.washington.edu/imap/documentation/locking.txt.html

Note that some of what they have to say is outdated; for example on
linux fcntl locking works fine on NFS, provided you use nfs-utils >=
0.3.1.  I believe it also works fine on Tru64 and on more recent
versions of other Unix flavors too, but I'm less sure of that.  I used
to work with a bunch of guys that worked on Linux's NFS code, and they
hammered on this hard in the lab to make sure it worked.

Overall though, I think their argument is a good one.

>  3. Procmail (again widely used on GNU/Linux) creates dot-lock, but
>     uses flock before writing to the mailbox (see locking.c,
>     mailfold.c).
>  4. Mutt: first applies kernel locking, then creates dot-lock
>     if requested (see mx.c).
> 
> The overall situation confirms that the widely-used mail programs will
> honour kernel locking.

But, what about ones that don't?  What about those that use a spool
exported via NFS from a system that doesn't support fcntl locking or
has a broken lockd and/or statd?

Also, don't forget that Linux and QNX are not the only systems out
there.  If you want to stay portable, you can't assume kernel locking
even exists, never mind works.  Some older Unix systems (and there are
plenty of them still out there) don't support it at all.

Xy



reply via email to

[Prev in Thread] Current Thread [Next in Thread]