I have been in communication with some experts on file locking. The
algorithm that Exim uses can be improved. This might save a bit of time
on any system, but the improvement also means that on systems where the
inode cache is not updated after link(), it will still work most of the
time. In the next version of Exim, the code around line 915 of
src/transports/appendfile.c, which currently reads
link(hitchname, lockname);
fstat(hd, &statbuf);
close(hd);
unlink(hitchname);
if (statbuf.st_nlink != 2)
{
has been changed to
int rc;
if ((rc = link(hitchname, lockname)) != 0) fstat(hd, &statbuf);
close(hd);
unlink(hitchname);
if (rc != 0 && statbuf.st_nlink != 2)
{
The case where this will fail is if the link() function fails, but the
hard link has in fact been made (can happen if the NFS server crashes
and reboots). However, Exim will try again, so it shouldn't be a
permanent failure.
There also appears to be some consensus that Linux's lack of updating
its cache isn't right, and the author of Linux NFS said this will be
changed in a forthcoming version.
--
Philip Hazel University Computing Service,
ph10@??? New Museums Site, Cambridge CB2 3QG,
P.Hazel@??? England. Phone: +44 1223 334714