Return-Path: Delivered-To: apmail-apr-dev-archive@apr.apache.org Received: (qmail 24652 invoked by uid 500); 11 Jul 2003 17:13:48 -0000 Mailing-List: contact dev-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Delivered-To: mailing list dev@apr.apache.org Received: (qmail 24593 invoked from network); 11 Jul 2003 17:13:48 -0000 Message-ID: <263A1F717ECDED40AA969F98D1CF122E0F784E@penxng.smca.yahoo.com> From: "Viner, David" To: "'Gregory (Grisha) Trubetskoy'" , dev@apr.apache.org Subject: RE: Getting a hash table into shared memory Date: Fri, 11 Jul 2003 10:13:10 -0700 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2656.59) Content-Type: text/plain; charset="iso-8859-1" X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Must your shared memory be SysV style? How about mmap() a file? Outside the Apache world, there is a really cool library called MDBM which is owned by Larry McVoy at BitMover. It is similar to sdbm except that it uses mmap() to get (and keep) most or all the hash in memory. dave -----Original Message----- From: Gregory (Grisha) Trubetskoy [mailto:grisha@apache.org] Sent: Friday, July 11, 2003 9:02 AM To: dev@apr.apache.org Subject: 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