From owner-freebsd-current@FreeBSD.ORG Thu Mar 14 16:28:26 2013 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 35EC975E; Thu, 14 Mar 2013 16:28:26 +0000 (UTC) (envelope-from pawel@dawidek.net) Received: from mail.dawidek.net (garage.dawidek.net [91.121.88.72]) by mx1.freebsd.org (Postfix) with ESMTP id E7C869CE; Thu, 14 Mar 2013 16:28:25 +0000 (UTC) Received: from localhost (58.wheelsystems.com [83.12.187.58]) by mail.dawidek.net (Postfix) with ESMTPSA id 2CA0593F; Thu, 14 Mar 2013 17:25:11 +0100 (CET) Date: Thu, 14 Mar 2013 17:29:58 +0100 From: Pawel Jakub Dawidek To: John Baldwin Subject: Re: pidfile_open incorrectly returns EAGAIN when pidfile is locked Message-ID: <20130314162958.GD1344@garage.freebsd.pl> References: <513F8D20.2050707@erdgeist.org> <51417C19.9060002@erdgeist.org> <20130314084420.GH1372@garage.freebsd.pl> <201303140942.40945.jhb@freebsd.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="Ns7jmDPpOpCD+GE/" Content-Disposition: inline In-Reply-To: <201303140942.40945.jhb@freebsd.org> X-OS: FreeBSD 10.0-CURRENT amd64 User-Agent: Mutt/1.5.21 (2010-09-15) Cc: Dirk Engling , freebsd-current@freebsd.org X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Mar 2013 16:28:26 -0000 --Ns7jmDPpOpCD+GE/ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Mar 14, 2013 at 09:42:40AM -0400, John Baldwin wrote: > On Thursday, March 14, 2013 4:44:20 am Pawel Jakub Dawidek wrote: > > On Thu, Mar 14, 2013 at 08:28:25AM +0100, Dirk Engling wrote: > > > -----BEGIN PGP SIGNED MESSAGE----- > > > Hash: SHA1 > > >=20 > > > On 13.03.13 23:08, Pawel Jakub Dawidek wrote: > > >=20 > > > > I think I considered something similar at first, but the change I= =20 > > > > proposed was optimal, IMHO at the cost of producing pretty large > > > > diff, because of indentation change. But to be sure, can you send a > > > > patch of your proposed change? > > >=20 > > > http://erdgeist.org/arts/software/Code/pidfile.c.diff > >=20 > > Right. Your patch assumes EWOULDBLOCK is equal to EAGAIN, which is true > > on FreeBSD, but is not portable. Also in case pidptr is NULL you compare > > errno three times instead of just one (not a big deal of course, just > > something that could be done a bit more optimal:)). >=20 > Geeze, why not just add an else. That's the really short diff: Heh, I did consider that as well, but here you check errno twice, instead of once. Guys, is there anything wrong with the patch I proposed? > Index: pidfile.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- pidfile.c (revision 248162) > +++ pidfile.c (working copy) > @@ -140,7 +140,8 @@ pidfile_open(const char *path, mode_t mode, pid_t > *pidptr =3D -1; > if (errno =3D=3D 0 || errno =3D=3D EAGAIN) > errno =3D EEXIST; > - } > + } else if (errno =3D=3D EWOULDBLOCK) > + errno =3D EEXIST; > free(pfh); > return (NULL); > } --=20 Pawel Jakub Dawidek http://www.wheelsystems.com FreeBSD committer http://www.FreeBSD.org Am I Evil? Yes, I Am! http://tupytaj.pl --Ns7jmDPpOpCD+GE/ Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (FreeBSD) iEYEARECAAYFAlFB+wYACgkQForvXbEpPzRh2QCgza1GSffrMYCDy95g+AUzOrDM MxUAn2pE9dQ3l3Mr0cRrhfwmPeI2f3gb =hdBk -----END PGP SIGNATURE----- --Ns7jmDPpOpCD+GE/--