I did previously write apache modules in apache 1.3, but nowadays I'm prepared to pass to apache2. The module that i'm writing right now has is own binary data, not really a database, for performance reasons. I have to load this data in shared memory, so every child can can get on without making their own copy, and it might be practical to load/produce the binary data at startup, when i was adopted related to apache 1.3. Issue is which i don't locate an init event in apache2, in 1.3 within the module struct, immediatly after STANDARD_MODULE_STUFF you get a spot for a /** module initializer */, that you can put a function that'll be performed early. Body from the function I did previously write is one thing like:

if ( getppid == 1 )
{
     // Load global data here
     // this is the parent process
     void* data = loadGlobalData( someFilePath );
     setGlobalData( config, data );
}
else
{
    // this is the init of a child process
    // do nothing
}

I'm searching for a location in apache2 in where I'm able to put an identical function.

Are you able to help?

Thanks Benvenuto

Because you want the server to produce a single shared memory segment for use by all children, I would suggest initialising this within the publish config hook (ap_hook_publish_config). This really is known as when the configuration continues to be read, before the kids are created, therefore it should work nicely.

Use a child_init hook to initialize an origin which will keep going longer then request or connection.

typedef struct {
    apr_pool_t *pool;
    apr_hash_t *hash;
} my_server_config;

static void my_child_init(apr_pool_t *p, server_rec *s)
{
    my_server_config cfg = ap_get_module_config(s->module_config, &my_module);
    /* Create sub-pool: ap_pool_create(&cfg->pool, p); */
    /* Create hash: cfg->hash = ap_hash_make(cfg->pool); */
}

static void my_register_hooks(apr_pool_t *p)
{
    ap_hook_child_init(my_child_init, NULL, NULL, APR_HOOK_MIDDLE);
}

module AP_MODULE_DECLARE_DATA my_module =
{
    STANDARD20_MODULE_STUFF,
    NULL,  /* per-directory config creator */
    NULL,  /* dir config merger */
    NULL,  /* server config creator */
    NULL,  /* server config merger */
    NULL,  /* command table */
    my_register_hooks, /* set up other request processing hooks */
};

Child init hook is going to be known as before apache makes its way into operational mode or before threads are produced in threaded MPM. The pool passed in to the my_child_init function ought to be process pool.

For better example you need to download apache source code and appearance the modules/experimental/mod_example.c file.