You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Jim Jagielski <ji...@jaguNET.com> on 2007/04/09 16:26:57 UTC

apr_temp_dir_get()

Hmmm... While looking over some proxy changes, for some
reason my eyes were pulled to apr_temp_dir_get(). Note
that the comments state:

     "Our goal is to find a temporary directory suitable for writing
      into.  We'll only pay the price once if we're successful -- we
      cache our successful find."

Except we don't (cache); neither in 0.9.x or trunk.

So is the comment broken or the code? Methinks the code,
but I'm sure one reason was due to potential thread
safety issues... ?

Re: apr_temp_dir_get()

Posted by Jim Jagielski <ji...@jaguNET.com>.
Joe Orton wrote:
> 
> On Mon, Apr 09, 2007 at 10:26:57AM -0400, Jim Jagielski wrote:
> > Hmmm... While looking over some proxy changes, for some
> > reason my eyes were pulled to apr_temp_dir_get(). Note
> > that the comments state:
> > 
> >     "Our goal is to find a temporary directory suitable for writing
> >      into.  We'll only pay the price once if we're successful -- we
> >      cache our successful find."
> > 
> > Except we don't (cache); neither in 0.9.x or trunk.
> > 
> > So is the comment broken or the code? Methinks the code,
> > but I'm sure one reason was due to potential thread
> > safety issues... ?
> 
> The original apr_temp_dir_get() implementation did use a static variable 
> to cache the result, so that's probably what the comment refers to; but 
> as you suspect it wasn't thread safe so this was fixed.  (not sure if 
> the non-thread-safe-code even made it into a release)
> 

The 0.9.x branch version still uses a static global, but
it still goes ahead and checks all the envars, dirs, etc
anyway. In other words, it doesn't check for that the
static global has been used or not, it just re-does the
whole check and then tucks it away...

Sounds like we need to update the comments...

-- 
===========================================================================
   Jim Jagielski   [|]   jim@jaguNET.com   [|]   http://www.jaguNET.com/
	    "If you can dodge a wrench, you can dodge a ball."

Re: apr_temp_dir_get()

Posted by Joe Orton <jo...@redhat.com>.
On Mon, Apr 09, 2007 at 10:26:57AM -0400, Jim Jagielski wrote:
> Hmmm... While looking over some proxy changes, for some
> reason my eyes were pulled to apr_temp_dir_get(). Note
> that the comments state:
> 
>     "Our goal is to find a temporary directory suitable for writing
>      into.  We'll only pay the price once if we're successful -- we
>      cache our successful find."
> 
> Except we don't (cache); neither in 0.9.x or trunk.
> 
> So is the comment broken or the code? Methinks the code,
> but I'm sure one reason was due to potential thread
> safety issues... ?

The original apr_temp_dir_get() implementation did use a static variable 
to cache the result, so that's probably what the comment refers to; but 
as you suspect it wasn't thread safe so this was fixed.  (not sure if 
the non-thread-safe-code even made it into a release)

joe