Re: incorrect use of pidfile(3)

看板FB_current作者時間14年前 (2011/10/14 18:32), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串9/10 (看更多)
--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--
文章代碼(AID): #1Ec0-Zn9 (FB_current)
討論串 (同標題文章)
文章代碼(AID): #1Ec0-Zn9 (FB_current)