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

Re: thread safe

From: Branko Čibej <brane_at_wandisco.com>
Date: Tue, 04 Sep 2012 21:07:20 +0200

On 04.09.2012 20:42, Stefan Küng wrote:
> Seems I got confused here:
> What we have to pass to almost each svn API is the config hash for the
> svn_client_ctx_t struct. That's what I need a copy of.

The svn_config_* functions work with svn_config_t object. The tmp_key
and tmp_value fields in those object are in fact the ones that prevent
you from reading the same svn_config_t from multiple threads without
synchronization.

> And as Bert already noticed: apr_hash_copy only does a shallow copy,
> not a deep copy. Seems I have to iterate over the hash and copy every
> item separately.

That is correct. You'll also have to duplicate the svn_config_t
structure itself, I think that essentially means doing an
svn_config_create and copying over "x_values" and
"section_names_case_sensitive"; and, of course, doing the deep copy of
"sections".

If you do the deep copy properly -- i.e., copying the keys and values
into the new config_t's pool as well as the hashes -- then you'll save
yourself a bit of trouble with pool lifetimes, too.

> I'll do that first in TSVN, then do some tests.
> After that I can use that code to create an svn_config_dup() API if
> still required.

Why not just write svn_config_dup in libsvn_subr/config.c? Surely
there's no reason to keep this functionality out of the core libraries.

-- Brane

-- 
Certified & Supported Apache Subversion Downloads:
http://www.wandisco.com/subversion/download
Received on 2012-09-04 21:07:56 CEST

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.