You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by toni pérez <pl...@gmail.com> on 2005/12/27 18:22:29 UTC
[users@httpd] apache modules development,hash tables,pools and threads
Hi list,
My question is about modules programming.
I have an apache with mpm worker, every process makes a number of threads.
Can I use apr_hash interface, inside a module in a process pool
lifetime with mpm worker model?
Can I insert,read and delete data in hash tables from any request that
triguer my module?
thanks,
Re: [users@httpd] apache modules development,hash tables,pools and threads
Posted by Nick Kew <ni...@webthing.com>.
On Tuesday 27 December 2005 17:22, toni pérez wrote:
> Hi list,
>
> My question is about modules programming.
> I have an apache with mpm worker, every process makes a number of threads.
> Can I use apr_hash interface, inside a module in a process pool
> lifetime with mpm worker model?
> Can I insert,read and delete data in hash tables from any request that
> triguer my module?
Yes, no problem with that. Put the hash on the server config, of course.
There are a couple of caveats. Of course you'll need to use a thread mutex
when you update the hash during request processing. Put the mutex on
the server config, and create it in child_init. It would also be good
practice to have your module create its own subpool of the process
pool (also in child_init), rather than use the process pool itself in
request processing. Make sure your hash entries, as well as the
hash itself, are tied to your module's pool: the request pool will of course
go out of scope far too quickly!
The hardest bit if you're deleting hash entries is doing that without
giving rise to a memory leak. If it's sufficiently rare you might just live
with it; otherwise you should endeavour to re-use memory, or implement
garbage collection on your module pool.
BTW, the apache-modules list would be more on-topic for this.
--
Nick Kew
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org