NFS/Sendmail issue since upgrading to 4.9-STABLE
Claus Assmann
freebsd+stable at esmtp.org
Wed Nov 26 19:44:47 PST 2003
On Wed, Nov 26, 2003, Adam Maloney wrote:
> This custom application reads a directory list and for each qf file,
> attempts a LOCK_EX. For the past 2 years this has appeared to work fine
> with Sendmail - if Sendmail is still working on the qf file, we aren't able
> to get an exclusive lock, so we go on to the next file, etc. (Maybe Claus
> can confirm some of this behavior?)
>
> It appears that Sendmail changed from 8.12.9 (FreeBSD 4.8R) to 8.12.10
> (FreeBSD 4.9-STA). What we believe is happening is that the qf file is
> being created, and our application is getting the exclusive lock before
> Sendmail. This makes Sendmail spit out the "resource temporarily
> unavailable" error, since it can't lock the file, and it leaves our
> application with an empty qf file that we are trying to process.
Yes, there's a race condition. 8.12.10 changed the behavior to avoid
overwriting an existing qf file:
Better error handling in case of (very unlikely) queue-id conflicts.
tfd = open(tf, O_CREAT|O_WRONLY|O_EXCL, FileMode);
if (tfd < 0 ||
!lockfile(tfd, tf, NULL, LOCK_EX|LOCK_NB) ||
(tfp = sm_io_open(SmFtStdiofd, SM_TIME_DEFAULT,
So if your application accesses the qf file between open() and
lockfile() sendmail will complain and exit() without trying again.
Older versions would try again and eventually overwrite the file...
Fix 1: don't mess with qf files.
Fix 2: check the size before accessing a qf file: don't touch
(open/lock) empty files.
More information about the freebsd-stable
mailing list