[Mimedefang] flock vs. fcntl

Kelson Vibber kelson at speed.net
Wed Nov 15 17:48:11 EST 2006


Kris Deugau wrote:
> It's most likely intended for people running SpamAssassin;  relating
> to how it locks BerkeleyDB databases (Bayes and AWL).  flock() is
> faster, but isn't generally NFS-safe;  fcntl() is (more) NFS-safe but
> slower.

It is, in fact, a SpamAssassin configuration directive that should go in
sa-mimedefang.conf (or local.cf) if you choose to set it.

 From the Mail::SpamAssassin::Conf man page:

lock_method type

Select the file-locking method used to protect database files
on-disk. By default, SpamAssassin uses an NFS-safe locking method on
UNIX; however, if you are sure that the database files you'll be
using for Bayes and AWL storage will never be accessed over NFS, a
non-NFS-safe locking system can be selected.

This will be quite a bit faster, but may risk file corruption if the
files are ever accessed by multiple clients at once, and one or more
of them is accessing them through an NFS filesystem.

Note that different platforms require different locking systems.

The supported locking systems for type are as follows:

nfssafe - an NFS-safe locking system
flock - simple UNIX flock() locking
win32 - Win32 locking using sysopen (..., O_CREAT|O_EXCL).

nfssafe and flock are only available on UNIX, and win32 is only
available on Windows. By default, SpamAssassin will choose either
nfssafe or win32 depending on the platform in use.

-- 
Kelson Vibber
SpeedGate Communications <www.speed.net>




More information about the MIMEDefang mailing list