> Hello,
> How to load memory permanently between request?
> 
> Server handles  ap_hook_handler when request is made, but when request
> finish memory should be free ().
> 
> Any method to load memory when module start with apache, and unload
> when apache shut down ?

Hi,

I've just joined this list, and was looking through the archives to find
a FAQ or something.

Apologies if this is already answered.

I think what you're looking for is something that can allocate global
memory, which is generally a bad idea - unless you're going to instate
your own locking mechanism, to prevent requests clobbering each other
with the memory.


void *global_pointer = NULL;

int module_handler( ... ) {
        if( global_pointer == NULL ) {
                global_pointer = malloc( BUFFER*20 );

                /**
                 * uh oh, no free memory
                 */
                if( global_pointer == NULL ) {
                        return( EXIT_FAILURE );
                }
        }
}

Now, obviously the problem here, is that every request will try and
access the same block of memory, generally a bad idea. You will have to
put your own method of synchronisation into the module.

Generally, getting a memory from the kernel is no problem, and happens
very quickly, so it's not a big concern to call malloc once or twice per
request.

-- 
The Optical Cable to the FTP Server is smelling funky because of an
errant well-driller. The Cult of the Dead Cow is pumping a grumpy.
:: http://www.s5h.net/ :: http://www.s5h.net/gpg

Attachment: signature.asc
Description: PGP signature

Reply via email to