Re: pidfile_open incorrectly returns EAGAIN when pidfile is locked

2013-03-14 Thread John Baldwin
On Thursday, March 14, 2013 4:21:02 pm Pawel Jakub Dawidek wrote: > On Thu, Mar 14, 2013 at 10:11:07AM -0700, Chuck Swiger wrote: > > Hi-- > > > > On Mar 14, 2013, at 9:50 AM, John Baldwin wrote: > > > On Thursday, March 14, 2013 12:29:58 pm Pawel Jakub Dawidek wrote: > > > > [ ... ] > > >> Heh,

Re: pidfile_open incorrectly returns EAGAIN when pidfile is locked

2013-03-14 Thread Pawel Jakub Dawidek
On Thu, Mar 14, 2013 at 10:11:07AM -0700, Chuck Swiger wrote: > Hi-- > > On Mar 14, 2013, at 9:50 AM, John Baldwin wrote: > > On Thursday, March 14, 2013 12:29:58 pm Pawel Jakub Dawidek wrote: > > [ ... ] > >> Heh, I did consider that as well, but here you check errno twice, > >> instead of once.

Re: pidfile_open incorrectly returns EAGAIN when pidfile is locked

2013-03-14 Thread Chuck Swiger
Hi-- On Mar 14, 2013, at 9:50 AM, John Baldwin wrote: > On Thursday, March 14, 2013 12:29:58 pm Pawel Jakub Dawidek wrote: [ ... ] >> 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? > > I'm sure the

Re: pidfile_open incorrectly returns EAGAIN when pidfile is locked

2013-03-14 Thread John Baldwin
On Thursday, March 14, 2013 12:29:58 pm Pawel Jakub Dawidek wrote: > 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

Re: pidfile_open incorrectly returns EAGAIN when pidfile is locked

2013-03-14 Thread Dirk Engling
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 14.03.13 17:29, Pawel Jakub Dawidek wrote: > 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? Except some obvious bike shed color issues there is noth

Re: pidfile_open incorrectly returns EAGAIN when pidfile is locked

2013-03-14 Thread Pawel Jakub Dawidek
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 > > > > > > On 13.03.13 23:08, Pawel Jakub D

Re: pidfile_open incorrectly returns EAGAIN when pidfile is locked

2013-03-14 Thread John Baldwin
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 > > > > On 13.03.13 23:08, Pawel Jakub Dawidek wrote: > > > > > I think I considered something similar at first,

Re: pidfile_open incorrectly returns EAGAIN when pidfile is locked

2013-03-14 Thread Dirk Engling
On Thu, 14 Mar 2013, Pawel Jakub Dawidek wrote: 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 b

Re: pidfile_open incorrectly returns EAGAIN when pidfile is locked

2013-03-14 Thread Pawel Jakub Dawidek
On Thu, Mar 14, 2013 at 08:28:25AM +0100, Dirk Engling wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > On 13.03.13 23:08, Pawel Jakub Dawidek wrote: > > > I think I considered something similar at first, but the change I > > proposed was optimal, IMHO at the cost of producing pretty

Re: pidfile_open incorrectly returns EAGAIN when pidfile is locked

2013-03-14 Thread Dirk Engling
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 13.03.13 23:08, Pawel Jakub Dawidek wrote: > I think I considered something similar at first, but the change I > proposed was optimal, IMHO at the cost of producing pretty large > diff, because of indentation change. But to be sure, can you send a

Re: pidfile_open incorrectly returns EAGAIN when pidfile is locked

2013-03-13 Thread Pawel Jakub Dawidek
On Wed, Mar 13, 2013 at 10:59:17PM +0100, Dirk Engling wrote: > > On Wed, 13 Mar 2013, Pawel Jakub Dawidek wrote: > > > How about this patch? > > > > http://people.freebsd.org/~pjd/patches/pidfile.c.patch > > If you move the lines > > + if (errno == 0 || errno ==

Re: pidfile_open incorrectly returns EAGAIN when pidfile is locked

2013-03-13 Thread Dirk Engling
On Wed, 13 Mar 2013, Pawel Jakub Dawidek wrote: How about this patch? http://people.freebsd.org/~pjd/patches/pidfile.c.patch If you move the lines + if (errno == 0 || errno == EAGAIN) + errno = EEXIST; out of the e

Re: pidfile_open incorrectly returns EAGAIN when pidfile is locked

2013-03-13 Thread Pawel Jakub Dawidek
On Wed, Mar 13, 2013 at 11:18:36AM -0400, John Baldwin wrote: > On Tuesday, March 12, 2013 4:16:32 pm Dirk Engling wrote: > > While debugging my own daemon I noticed that pidfile_open does not > > perform the appropriate checks for a running daemon if the caller does > > not provide a pidptr to pid

Re: pidfile_open incorrectly returns EAGAIN when pidfile is locked

2013-03-13 Thread John Baldwin
On Tuesday, March 12, 2013 4:16:32 pm Dirk Engling wrote: > While debugging my own daemon I noticed that pidfile_open does not > perform the appropriate checks for a running daemon if the caller does > not provide a pidptr to pidfile_open > > fd = flopen(pfh->pf_path, > O_WRONLY | O_CREA

pidfile_open incorrectly returns EAGAIN when pidfile is locked

2013-03-12 Thread Dirk Engling
While debugging my own daemon I noticed that pidfile_open does not perform the appropriate checks for a running daemon if the caller does not provide a pidptr to pidfile_open fd = flopen(pfh->pf_path, O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC | O_NONBLOCK, mode); fails when another dae