Subject: Re: Mail and locking
To: Michael Graff <explorer@flame.org>
From: Scott Reynolds <scottr@Plexus.COM>
List: current-users
Date: 11/27/1996 16:47:51
On 26 Nov 1996, Michael Graff wrote:

> Other packages might or might not [use dot locks].  Movemail, for
> example, uses flock(), and a popper I have my hands on does as well.

This is probably a bad idea, especially since flock() is advisory-only
(`advisory' is even underlined in the man page) and doesn't work across
non-local filesystems.  While the latter may be evil, it is tolerated in
certain large environments; one would assume that they either
lockf()/fcntl()-style locks, or since NFS locking really isn't, they
would use dot locking.

> > [re:  potential deadlock]
> 
> Not really, since if you can't get both locks you back out of the one you
> did get, wait, and try again.  That should prevent the deadlocks if the
> programs retry at different times.

It looks like you're assuming that all cooperating processes here use
LOCK_NB with flock().  Is this a valid assumption?  If not, why is the
penalty to implement this substantially different than that incurred for
adding dot locking?

Using fcntl()-style locking, while being POSIX-compliant, also places
advisory locks only, and has some brain damage mandated by 1003.1-1988
that flock() doesn't have.

>From this perspective, it appears that the only "hard" locking we can do
is that which is already implemented.  It is not difficult to add the
necessary code to software that doesn't already do dot locking.

--scott

PS - have the other BSD folks done anything like this, by the way?