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

Re: Thread issues in svnserve

From: Philip Martin <philip.martin_at_wandisco.com>
Date: Thu, 09 May 2013 20:58:21 +0100

Ivan Zhakov <ivan_at_visualsvn.com> writes:

> Another way add some kind of svn__shared_pool_t with atomic reference
> counter and destroying attached pool when counter reaches zero.
>
> Something like this:
> [[[
> svn__shared_pool_t * svn__shared_pool_attach(apr_pool_t *pool)
> {
> svn__shared_pool_t sp = apr_pcalloc(pool);
> sp->counter = 1;
> sp->pool = pool;
> }
>
> void svn__shared_pool_addref(svn__shared_pool_t *sp)
> {
> apr_atomic_increment(sp->counter);
> }
>
> void svn__shared_pool_release(svn__shared_pool_t *sp)
> {
> if (apr_atomic_decrement(sp->counter) == 0)
> {
> svn_pool_destroy(sp->pool);
> }
> }
>
> Then we do the following:
> connection_pool = svn_pool_create();
> sp = svn__shared_pool_attach(connection_pool);
> svn__shared_pool_addref(sp); // for worker thread
> data->sp = sp;
> apr_threadattr_create(connection_pool);
> apr_thread_create(connection_pool, worker, data);
>
> svn_shared_pool_release(sp);
>
> void worker()
> {
> /// to the work
> svn_shared_pool_release(sp);
> }

Yes, that looks promising.

-- 
Certified & Supported Apache Subversion Downloads:
http://www.wandisco.com/subversion/download
Received on 2013-05-09 21:59:16 CEST

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