httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sorin Manolache <>
Subject Re: Apache pool management
Date Fri, 24 May 2013 21:23:29 GMT
On 2013-05-24 20:00, Sindhi Sindhi wrote:
> Hi,
> I did an initial study to find out more information about Apache APR pools.
> Some links say pools are not thread safe, some say they are really useful,
> so I'm a bit confused. Kindly advice.
> In certain links like the below, I read that pools are not thread safe.
> Does this mean that when multiple requests are being handled by multiple
> threads in Apache, data of one request could get overwritten/read/freed by
> other requests?
> A lot of other links like the below state that pools are a big advantage in
> Apache memory management.
> To summarize my requirement, I have written a C++ output filter module that
> filters HTML. And this module will be invoked by multiple requests that hit
> the server at the same time. My concern about using the APR pool is, if I
> use the request pools, when one request (say request1) is in the middle of
> processing, I do not want this request's data to be corrupted by other
> requests'(say request2) - like, request2 overwriting on request1's data or
> request2 freeing the memory allocated by request1.
> If you can answer the below questions that will help me make a better use
> or APR pool, kindly reply.
> 1. Can I use the request pools in such a way that, each request owns its
> pool and cannot be read/written/freed by other requests/pool manager? What
> settings in httpd-mpm.conf will make this possible?

Yes. I think it works out-of-the-box and does not need any special settings.

> 2. I get the "ap_filter_t *f" as an input to my filter module, and I'm
> using the f->r->pool to allocate memory that is used by my filter module.
> So is this pool unique for every request?

Yes. Each request owns its pool. Concurrent requests are handled in 
different threads, but the threads cannot access another thread's 
request structure, and implicitly cannot access another request's pool.

I don't know if pools are thread-safe. However, as stated here, sub-pool 
creation is thread-safe. The pool owned by a request is a sub-pool of 
the connection pool. So apache creates, in a thread-safe manner, the 
request pool for your exclusive use. So it should be safe. Personally 
I've never had concurrency issues with request pools.


> Would appreciate a response.
> Thanks.

View raw message