[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [PATCH] fix for issue #2556: support working copies on the root of a (virtual) drive

From: Erik Huelsmann <ehuels_at_gmail.com>
Date: 2006-08-21 22:31:46 CEST

On 8/21/06, Garrett Rooney <rooneg@electricjellyfish.net> wrote:
> On 8/21/06, Erik Huelsmann <ehuels@gmail.com> wrote:
>
> > Ok. I didn't investigate more of it myself, so I rely on you to make
> > sure that we call svn_path_is_root from other functions which don't
> > have a pool (excluding is_canonical, since Philip said we can safely
> > remove that function from consideration).
> >
> > However, calling svn_pool_create(NULL) isn't thread safe AFAIK,
> > because it allocates from the main pool (is this right, Branko,
> > anybody?). Or is that the only bit for which the main pool *is*
> > protected?
> >
>
> Incorrect, creating a new global pool (via svn_pool_create(NULL))
> should be thread safe (allocating things directly from the global pool
> yourself is not necessarily thread safe though, although you have to
> jump through hoops to get a handle on it anyway), it's just not
> something you really want to do very often because it's kinda slow.
> Creating a new pool involves allocating about 8k of data, which is
> kind of silly if you're just going to use it for one tiny thing then
> destroy it.

Reading it Garrett's way: we may want to rev the APIs just because of
the pool requirement. But, when the pool being passed in is NULL (as
the old api compat routines would), we'd need to create our own pool
with svn_pool_create(NULL); something along these lines:

svn_boolean_t
svn_path_is_root(const char *path, apr_size_t len, apr_pool_t *pool)
{
  char *root_path = NULL;
  apr_status_t status;
  apr_pool_t *strpool = (pool) ? NULL : svn_pool_create(NULL);
  char *rel_path = apr_pstrmemdup(strpool, path, len);
  svn_error_t *err;

  if (! pool)
    pool = strpool;
  /* svn_path_cstring_from_utf8 will create a copy of path.

     It should be safe to convert this error to a false return value. An error
     in this case would indicate that the path isn't encoded in UTF-8, which

     will cause problems elsewhere, anyway. */
  if (err = svn_path_cstring_from_utf8(&rel_path, rel_path, strpool))
  {
    svn_error_clear(err);
    if (strpool)
      apr_pool_destroy(strpool);
    return FALSE;
  }

  status = apr_filepath_root(&root_path, &rel_path, 0, strpool);

  if ((status == APR_SUCCESS ||
       status == APR_EINCOMPLETE) &&
      rel_path[0] == '\0')
  {
    if (strpool)
      apr_pool_destroy(strpool);
    return TRUE;
  }

  if (strpool)
    apr_pool_destroy(strpool);
  return FALSE;
}

HTH,

Erik.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Mon Aug 21 22:43:58 2006

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.