Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 14 Oct 2011 12:05:22 +0200
From:      Pawel Jakub Dawidek <pjd@FreeBSD.org>
To:        Dag-Erling =?iso-8859-1?Q?Sm=F8rgrav?= <des@des.no>
Cc:        current@freebsd.org
Subject:   Re: incorrect use of pidfile(3)
Message-ID:  <20111014100520.GA1635@garage.freebsd.pl>
In-Reply-To: <86mxd59e1v.fsf@ds4.des.no>
References:  <86pqi1b1qp.fsf@ds4.des.no> <864nzdaw7b.fsf@ds4.des.no> <20111013134841.GF1667@garage.freebsd.pl> <86mxd59e1v.fsf@ds4.des.no>

next in thread | previous in thread | raw e-mail | index | archive | help

--KsGdsel6WgEHnImy
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Thu, Oct 13, 2011 at 04:11:40PM +0200, Dag-Erling Sm=F8rgrav wrote:
> Pawel Jakub Dawidek <pjd@FreeBSD.org> writes:
> > I'm still in opinion that EWOULDBLOCK and EAGAIN (which is the same
> > value on FreeBSD) should be converted to EEXIST on pidfile_open()
> > return.
>=20
> The historical (and documented) behavior is to return EAGAIN.

We don't want to duplicate the code of handling EAGAIN into every single
pidfile(3) consumer. This is why we hav pidfile(3) API in the first
place - to make it easy for people to use.

> > Also if we now have for loop, why not to put count in there?
>=20
> Because if we do, there will be a nanosleep after the last
> pidfile_read() attempt.  We need to break the loop after pidfile_read()
> failed but before nanosleep().

Right, ok.

> > I'm not very happy about touching pidptr in case of error other than
> > EEXIST. This is not documented, but a bit unexpected anyway.
>=20
> Well, it was your idea, I just moved it to before the loop :)

In my patch *pidptr was set to -1 only in the case of EAGAIN from
pidfile_read(), not for every other error.

BTW. With your patch we will continue even when flopen(3) failed for
other reasons, instead of returning NULL. Checking for fd being -1
should not be done in the same statement with other checks.

After proposed changes it would look like this, what do you think?

	http://people.freebsd.org/~pjd/patches/pidfile.3.patch

--=20
Pawel Jakub Dawidek                       http://www.wheelsystems.com
FreeBSD committer                         http://www.FreeBSD.org
Am I Evil? Yes, I Am!                     http://yomoli.com

--KsGdsel6WgEHnImy
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (FreeBSD)

iEYEARECAAYFAk6YCWAACgkQForvXbEpPzT4GwCfeqfL6imNSNtIuYdQ/GZQg69v
UYkAn2kFa2uQmESGl+BGjWuRjR//nXCp
=HrI4
-----END PGP SIGNATURE-----

--KsGdsel6WgEHnImy--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20111014100520.GA1635>