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

Re: flock() and sendmail



On Fri, Nov 17, 2006 at 06:27:13PM +0000, John Kelly wrote:
> On Fri, 17 Nov 2006 19:09:33 +0100, Kurt Roeckx <kurt@roeckx.be>
> wrote:
> 
> >Anyway, from the linux/Documentation/locks.txt file:
> >1.2.1 Typical Problems - Sendmail
> >---------------------------------
> >Because sendmail was unable to use the old flock() emulation
> 
> I believe flock() *emulation* is no longer used in 2.6 kernels.

flock was changed to not use emulation in 1.3.x and the old flock
emulation has been removed in 2.1.x, according to the same
doc.

> >installations use fcntl() instead of flock(). This is true of Slackware 3.0
> >for example. This gave rise to some other subtle problems if sendmail was
> >configured to rebuild the alias file. Sendmail tried to lock the aliases.dir
> >file with fcntl() at the same time as the GDBM routines tried to lock this
> >file with flock(). With pre 1.3.96 kernels this could result in deadlocks that,
> >over time, or under a very heavy mail load, would eventually cause the kernel
> >to lock solid with deadlocked processes.
> 
> Then I have to wonder why sendmail is still configured to use fcntl()
> when running on linux.  Sounds like the modern kernel implementation
> of flock() would be better.

I have to wonder why sendmail needs to use fcntl() or flock() at all to
lock the database.

I don't see why flock() would be better, it's just different.  fcntl()
is a standardised and can do more than flock().  I actually see no good
reason to want to use flock() over fcntl().

Also note that this deadlock was caused by the flock() emulation.


Kurt



Reply to: