[redland-dev] Threads

Brendan anarch at silcom.com
Sat Sep 12 10:40:25 CEST 2009


Dave Beckett wrote:
>
> 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?
>
> In general it should be OK, but the cache module is newer and the  
> above
> looks suspicious to me.  Since threading is rather hard to get  
> right, it
> needs somebody who knows it to identify and fix problems.

Hi, thanks for your answer.  I've been inadvertantly offline for the  
last week -- sorry not to reply sooner.  These two examples are clear  
bugs.  They're both manifested straight from the cache test code.   
Perhaps it's only the new cache stuff, but I don't see how to turn  
that off.  And it makes me wonder about other parts of Redland thread  
management.

External locking for redland isn't really difficult for my  
application, but it's cumbersome, and the presence of WITH_THREADS  
and related build options does encourage a new user to expect built- 
in thread handling.  I'm going to put external locks on for now. I  
hope as I get to know Redland better I'll be able to give more useful  
suggestions.

-Brendan 


More information about the redland-dev mailing list