httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sorin Manolache <sor...@gmail.com>
Subject Re: Using apr_hash_t within shared memory
Date Wed, 21 Mar 2012 11:44:39 GMT
On 2012-03-21 12:31, Rajalakshmi Iyer wrote:
> Hello,
>
> I want to be able to store a hash map (apr_hash_t) in the Apache shared
> memory (created using apr_shm_create). This map will be created once and
> will be shared by all child processes.
>
> However, when I try to access the hash stored in the shared memory, I get a
> segmentation fault (because the hash appears empty).
>
> I have ensured that I use the apr_shm_baseaddr_get to get the starting
> address for the map in shared memory correctly.
>
> However that does not seem to help.
>
> Note that I have tried the same code with simple data structures like char*
> etc and it works. Do I need to do something more to get a hash into and out
> of the shared memory?
>
> Thanks in advance!

I don't think you can put it into shared memory. It uses an apr_pool in 
order to allocate new data when you add elements to the hash. The 
apr_pool will allocate non-shared memory.

If your code is C++ or can be migrated to C++, have a look here: 
http://www.boost.org/doc/libs/1_49_0/doc/html/interprocess/allocators_containers.html#interprocess.allocators_containers.containers_explained

Sorin

Mime
View raw message