On Nov 24, 2006, at 7:58 AM, Christiaan Lamprecht wrote:

typedef struct {
    char* variable1;
    char* variable2;
} ASSLFilter;

apr_shm_create(&assl_shm, sizeof(ASSLFilter) * 20, (const char *)
shmfilename, pconf);

<..>

Can I make use of shm to extend the memory for each char* in the
struct? e.g. shm_attach

All you end up having shared are the pointers to your strings. Other processes can't see that data those point to, because that lives within the process environment of the process that made the initial assignment.

You could make your shared memory segment large enough to hold the entire strings (say, char[256] variable1;), but you'll need to be careful to avoid buffer overflow issues especially if you fill that variable with remote input.

Another approach would be to create a second (and third) shm segment, and stash pointers to those in the first record. The child processes would check those pointers for NULL, and if they exist, attach to the shared segments and use them.

Of course this is kind of inefficient if the data for variable1 and variable2 itself is variable in size... makes it almost interesting to look at some database structure behind your module that abstracts the issues associated with variable size data. Don't we have bdb capability now inside the server?

S.

--
[EMAIL PROTECTED]            http://www.temme.net/sander/
PGP FP: 51B4 8727 466A 0BC3 69F4  B7B8 B2BE BC40 1529 24AF


Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to