httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sorin Manolache <sor...@gmail.com>
Subject Re: thread safety and mpm-prefork
Date Tue, 11 Jun 2013 20:10:37 GMT
On 2013-06-11 21:20, Alex Bligh wrote:
> I've written a module which I believe to be thread-safe but appears to be
> doing something which I have put down to a lack of thread safety in pool
> management (somewhere).
>
> Before I tear my hair out here, my module is running with apache 2.2.22
> and mpm-prefork on Ubuntu. Do the thread primatives actually do anything in
> mpm-prefork? I'm using apr_thread_create to create a thread, then
> providing a separate allocator, mutex, pool and similar (all as
> recommended). But if the mutex stuff is 'optimised out' of my apr
> library - specifically the pool stuff - all this will be in vain.
>

apr_* and mpm_prefork are different software packages and ubuntu 
distributes them separately. So it is almost certain that you have a 
thread-enabled libapr (i.e. compiled with APR_HAS_THREADS). You would 
not be able to compile the code that uses apr_thread_create if your 
libapr was not compiled with thread support.

mpm_prefork is like any ordinary client of libapr. Just that it does not 
use the threading functionality in libapr. So it cannot disable/optimise 
out the mutexes in libapr.

Please be aware that apr_pools are not thread-safe. Only the creation of 
subpools is thread-safe. So you should create a subpool per thread to 
stay safe.

Sorin

Mime
View raw message