[redland-dev] Threads

Michael Stahl Michael.Stahl at Sun.com
Mon Sep 7 18:46:33 CEST 2009


Brendan Hahn wrote:
> No response to my message of last week, so let me try again.  It's
> pretty simple: librdf_cache_set_common locks the world mutex, calls
> librdf_cache_cleanup, which calls librdf_cache_delete, which locks the
> world mutex.  pthreads mutexes are non-recursive by default, thus
> deadlock.  So I can fix this by setting PTHREAD_MUTEX_RECURSIVE at init
> time, but how was this supposed to work?
> 
> Further, there's this from librdf_free_cache: LIBRDF_FREE(librdf_cache,
> cache);
> 
> #ifdef WITH_THREADS pthread_mutex_unlock(cache->world->mutex); #endif
> 
> So I'm just not feeling confident about Redland's thread support in
> general.  Can anyone allay my concerns?

[oops, it seems gmane ate my first reply...]

well, the thread support in redland (i'm using version 1.0.8 currently) is
only for unix (pthreads); unfortunately i need it to work on win32 as
well, so i've wrapped the librdf_world with a mutex.

(oh, and it is indeed _the_ librdf_world; create only one instance per
process, and never free it; unfortunately it does not encapsulate its
dependencies very well, and freeing a librdf_world will e.g. result in
freeing the global data of libxml2, which makes other users of libxml2
rather unhappy)... of course, this is ultimately awful design on libxml2's
part: global variables are Evil(TM)...)

regards,
michael

-- 
"Neither a man nor a crowd nor a nation can be trusted to act humanely
 or to think sanely under the influence of a great fear."
 -- Bertrand Russell



More information about the redland-dev mailing list