httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Saju Pillai <saju.pil...@gmail.com>
Subject Re: custom background thread and module sharing a data structure
Date Fri, 13 Mar 2009 15:41:52 GMT
Andrej van der Zee wrote:
> Hi Saju,
> 
> For the worker mpm, both cross thread and cross process protection will be
>> needed. apr_proc_mutex.h family supplies cross-process protection,
>> apr_thread_mutex.h provides cross thread protection.
>>
>> You "locking" method would be a wrapper method that first obtains a process
>> level lock, and then inside that lock it obtains a thread level lock.
>>
> 
> In my specific case, do I really need thread-level locking in addition to
> process-level locking? Since I am running a background thread that is
> started in post_config(), worker-threads in the mpm worker model are running
> in a different process then my background thread anyway. So I guess
> process-level locking should suffice, or am I overlooking something?

Worker mpm is a multithreaded, multiprocess mpm. Multiple child 
processes host multiple worker threads that run your module code.

If your module services 2 concurrent requests in 2 different threads in 
the same process and both the threads need to access critical code at 
the same time, you will have to use thread locking to prevent race 
conditions.

re: Using non APR locking mechanisms - sure they will work as long as 
you are using compatible mechanisms (like if apr_threads is based on 
pthreads, the alternate locking mechanism should work with pthreads).


srp
-- 
http://saju.net.in

Mime
View raw message