Re: [users@httpd] apache modules development,hash tables,pools and threads

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx



[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux