Date: Wed, 26 Nov 2003 19:45:54 -0800 From: Claus Assmann <freebsd+stable@esmtp.org> To: freebsd-stable@freebsd.org Subject: Re: NFS/Sendmail issue since upgrading to 4.9-STABLE Message-ID: <20031127034554.GA19264@zardoc.esmtp.org> In-Reply-To: <00a401c3b46a$78cd7650$41c3c3cf@office.sihope.com> References: <004f01c3b427$eaea8c70$41c3c3cf@office.sihope.com> <008601c3b455$379b72a0$41c3c3cf@office.sihope.com> <00a401c3b46a$78cd7650$41c3c3cf@office.sihope.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20031127034554.GA19264>
