You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by David Glasser <gl...@davidglasser.net> on 2007/10/12 22:05:23 UTC

[PATCH] svnserve: write pid a bit earlier?

So one of my test scripts essentially does

  svnserve -d -r bla --pid-file .svnserve-pid
  spid=`cat .svnserve-pid`
  run some tests
  kill -9 $spid

... except that sometimes the shell manages to cat the PID file before
it's written.  Any reason not to apply the attached patch?  (Like, the
proc detach doesn't change the PID or anything weird like that,
right?)

--dave

[[[
* subversion/svnserve/main.c
  (main): Write the PID file before detaching, so that the process
that runs svnserve
   can read it immediately.
]]]

-- 
David Glasser | glasser@davidglasser.net | http://www.davidglasser.net/

Re: [PATCH] svnserve: write pid a bit earlier?

Posted by Karl Fogel <kf...@red-bean.com>.
"David Glasser" <gl...@davidglasser.net> writes:
> So one of my test scripts essentially does
>
>   svnserve -d -r bla --pid-file .svnserve-pid
>   spid=`cat .svnserve-pid`
>   run some tests
>   kill -9 $spid
>
> ... except that sometimes the shell manages to cat the PID file before
> it's written.  Any reason not to apply the attached patch?  (Like, the
> proc detach doesn't change the PID or anything weird like that,
> right?)

Looks sensible to me.  I don't know of any weirdnesses that would make
this not work.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

[PATCH] svnserve: write pid a bit earlier?

Posted by David Glasser <gl...@davidglasser.net>.
On 10/13/07, Eric Gillespie <ep...@pretzelnet.org> wrote:
> Eric Gillespie <ep...@pretzelnet.org> writes:
>
> > "David Glasser" <gl...@davidglasser.net> writes:
> >
> > >   svnserve -d -r bla --pid-file .svnserve-pid
> > >   spid=`cat .svnserve-pid`
> > >   run some tests
> > >   kill -9 $spid
> >
> > I don't object to your change, but all you do is shorten the
> > race: it's inherent in the pidfile practice.  What you want is:
> >
> >   svnserve -d -r bla --foreground &
> >   spid=$!
> >   run some tests
> >   kill -9 $spid
>
> Now that I think about it, I think your patch is broken.  You
> write the PID of the svnserve you started, but it then forks off
> the one that hangs around.  I have not tested this, or even
> looked up apr_proc_detach, so I may be wrong.

Looking at the source for apr_proc_detach, you are correct and there
is no way that my patch works.  On the other hand, I think my patch
works.

--dave

--
David Glasser | glasser@davidglasser.net | http://www.davidglasser.net/

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: [PATCH] svnserve: write pid a bit earlier?

Posted by Eric Gillespie <ep...@pretzelnet.org>.
Eric Gillespie <ep...@pretzelnet.org> writes:

> "David Glasser" <gl...@davidglasser.net> writes:
> 
> >   svnserve -d -r bla --pid-file .svnserve-pid
> >   spid=`cat .svnserve-pid`
> >   run some tests
> >   kill -9 $spid
> 
> I don't object to your change, but all you do is shorten the
> race: it's inherent in the pidfile practice.  What you want is:
> 
>   svnserve -d -r bla --foreground &
>   spid=$!
>   run some tests
>   kill -9 $spid

Now that I think about it, I think your patch is broken.  You
write the PID of the svnserve you started, but it then forks off
the one that hangs around.  I have not tested this, or even
looked up apr_proc_detach, so I may be wrong.

-- 
Eric Gillespie <*> epg@pretzelnet.org

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: [PATCH] svnserve: write pid a bit earlier?

Posted by Eric Gillespie <ep...@pretzelnet.org>.
"David Glasser" <gl...@davidglasser.net> writes:

>   svnserve -d -r bla --pid-file .svnserve-pid
>   spid=`cat .svnserve-pid`
>   run some tests
>   kill -9 $spid

I don't object to your change, but all you do is shorten the
race: it's inherent in the pidfile practice.  What you want is:

  svnserve -d -r bla --foreground &
  spid=$!
  run some tests
  kill -9 $spid

-- 
Eric Gillespie <*> epg@pretzelnet.org

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org