Re: Pre2.0-8 & Sendmail

Andrew Walker (andy@lysaker.kvaerner.no)
Fri, 31 May 1996 07:57:09 +0200 (MET DST)


John Henders wrote:
>
>
> In <9605290611.AA26813@lysaker.kvaerner.no> andy@lysaker.kvaerner.no (Andrew Walker) writes:
>
> >Recompile your sendmail to lock with flock() (#define HASFLOCK I think).
> >In newer kernels I disallowed mixing BSD (flock) and SYSV(lockf)/POSIX(fcntl)
> >locks on a file. The GDBM routines use flock() to lock the alias database,
> >and then sendmail tries to lock the same files with lockf() - hence the
> >problem.
>
> You might want to reconsider your recommendation for flock() as the
> standard. I agree that mixed locks are a bad thing, but standardizing on
> flock means anyone wanting to try doing locking over NFS will have to
> maintain custom versions of the system libraries. Debian has already
> changed their gdbm to use fcntl() locking.
>
> Is there any particular reason to recommending flock()? My book on Posix
> programming uses fcntl() and calls flock() a BSD'ism.
>
>

flock() *is* a BSD'ism, and one of the better ones ;-)

I'm not really advocating one style or the other, although flock() has much
better semantics(*) with the exception of NFS locking. The problem in this case
is that people already have GDBM libraries that use flock(), and if sendmail
is compiled to use these libraries then sendmail must use flock() as well.

Personally I'd compile with the Berkeley DB library instead of GDBM and stop
worrying about flock() vs fcntl(). Eric Allman tried to switch over to fcntl()
as the sendmail standard. He ended up recommending flock() as the only method
that had sensible behaviour on all platforms that support it.

-Andy

(*) - especially for a program that forks a lot and wants to share locks with
its children

-- 
Andy Walker                              Kvaerner Engineering a.s.
Andrew.Walker@lysaker.kvaerner.no        P.O. Box 222, N-1324 Lysaker, Norway

......if the answer isn't violence, neither is your silence......