Return-Path: X-Original-To: apmail-httpd-modules-dev-archive@minotaur.apache.org Delivered-To: apmail-httpd-modules-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 828139AF7 for ; Wed, 21 Mar 2012 11:45:15 +0000 (UTC) Received: (qmail 27920 invoked by uid 500); 21 Mar 2012 11:45:15 -0000 Delivered-To: apmail-httpd-modules-dev-archive@httpd.apache.org Received: (qmail 27888 invoked by uid 500); 21 Mar 2012 11:45:15 -0000 Mailing-List: contact modules-dev-help@httpd.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: modules-dev@httpd.apache.org Delivered-To: mailing list modules-dev@httpd.apache.org Received: (qmail 27880 invoked by uid 99); 21 Mar 2012 11:45:15 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 21 Mar 2012 11:45:15 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of sorinm@gmail.com designates 209.85.214.45 as permitted sender) Received: from [209.85.214.45] (HELO mail-bk0-f45.google.com) (209.85.214.45) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 21 Mar 2012 11:45:07 +0000 Received: by bkcjg9 with SMTP id jg9so1042665bkc.18 for ; Wed, 21 Mar 2012 04:44:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=x3k3PSgB0n3hi6Q4ucZSzRBNUU4SUAj9izj3qIKBw1s=; b=Htm9VH0L8QCst0hDeqeRMABCpsINc6LgJ3wbyIaD9C4P8V/Rk+Db31mDO7zHT4qYpD Nhszz+sFAQDMrecfOGYMM2VhNY4TDhGo8NerVuEXozTCNR4G5IeSOP7DndENHSe6t4Vb gzVPbyVG1Z4gXE4msLPveR7+wh0D59AnAYJL8yE+j5UCd6h5JJDG0N23wazVuuRNn1Hm 4Myn9TFBOkJRI95agMRBxropyEaXrPG5bg+xCqeVOeexgOYseYjO+aZDGdRs5gPy43nr Z1Hgd18+QcvW2iy5Ie99Hfg1l+hHebMA7KvUGaMauYAtUTAooCYDAWqXs2iKIzeWo/73 BMEg== Received: by 10.204.156.204 with SMTP id y12mr1368934bkw.130.1332330287300; Wed, 21 Mar 2012 04:44:47 -0700 (PDT) Received: from [10.234.174.118] ([193.252.149.222]) by mx.google.com with ESMTPS id u14sm2954077bkp.2.2012.03.21.04.44.44 (version=SSLv3 cipher=OTHER); Wed, 21 Mar 2012 04:44:45 -0700 (PDT) Message-ID: <4F69BF27.5070802@gmail.com> Date: Wed, 21 Mar 2012 12:44:39 +0100 From: Sorin Manolache User-Agent: Mozilla/5.0 (X11; Linux i686; rv:8.0) Gecko/20120216 Icedove/8.0 MIME-Version: 1.0 To: modules-dev@httpd.apache.org Subject: Re: Using apr_hash_t within shared memory References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org 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