You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by "Gregory (Grisha) Trubetskoy" <gr...@apache.org> on 2003/07/11 18:01:45 UTC

Getting a hash table into shared memory

Hi -

I'm in search of some wisdom here.

I am looking at ways to have a hashtable into shared memory. This is for
mod_python, so maximum reliance on APR and least replication of effort is
a requirement.

I have seen a couple of examples in httpd code - mod_ssl and mod_auth_ldap
can use shared memory for caching their internal data. Both of those use
their own hash table implementation. Actually mod_ssl uses a hash table by
Gray Watson (with its own license). The reasons are probably historical,
but from looking at APR, it seems to me that it's not possible to use the
APR hash table for this purpose. I'm hesitant to borrow from these
examples because although they work, it seems there should be a more
elegant way of doing this.

Just to clarify, there are two possible ways to use shared memory. The
first is when the shared memory segment is allocated prior to forking and
its base address is reused by children, in which case addresses are all
the same and there is no need to deal with offsets. The only requirement
is that a different malloc-like functions are used (both mod_ssl and
auth_ldap use wrappers around APR rmm funcs).

The second is when a (child) process would be able to allocate a shared
memory segment and others could attach to it.  This, of course is a lot
more complicated, because now the base address may differ from process to
process and the table needs to deal with offsets.  Both examples mentioned
above do it the first way, and for my pusposes it would be acceptable,
though the second would be fantastic...

In any event, I'd appreciate some pointers or suggestions. Is it possible
for example to somehow create a pool that would use rmm_alloc functions?

Grisha

Re: Getting a hash table into shared memory

Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
At 11:01 AM 7/11/2003, Gregory (Grisha) Trubetskoy wrote:

>Just to clarify, there are two possible ways to use shared memory. 
>...
>The second is when a (child) process would be able to allocate a shared
>memory segment and others could attach to it.  This, of course is a lot
>more complicated, because now the base address may differ from process to
>process and the table needs to deal with offsets.  Both examples mentioned
>above do it the first way, and for my pusposes it would be acceptable,
>though the second would be fantastic...

Notice the apr_rmm API, it was designed entirely for this purpose, where
memory is described in size and relative position, not in absolute addresses.

It won't address your entire hashtable requirements, but it is a start to your
memory addressing issues.

Bill