Pb with module initialization

MAGNIEN, Thierry thierry.magnien at sfr.com
Fri Aug 17 12:58:38 UTC 2012

>>> A shared memory zone has a constructor, namely, init() method in
>>> ngx_shm_zone_t. This method is invoked by ngx_init_cycle() when the
>>> configuration is already processed and the shared memory zones are
>>> about to be (re)initialized, so I guess you can accees both your
>>> directives and the actual shm zone data from there. See file cache
>>> initialization routine ngx_http_file_cache_init() in
>>> src/http/ngx_http_file_cache.c for an example.
>> Well, I have such an init method but its arguments are only (ngx_shm_zone_t *shm_zone, void *data). I suppose I must use ngx_get_conf but what arguments should I give to it ?
>You can access your module main configuration with
>ngx_http_cycle_get_module_main_conf()  through the global ngx_cycle
>that has the module contexts already set up by the shm initialization
>time. You can also access the configuration from the module
>init_process() method that is explicitly given the cycle. Either way,
>you can pass any parameters you need to the shm zone constructor
>through the zone data field that is to be installed right after the
>shm zone is added  at the module configuration time.

Just found out this, our messages crossed each other ;-)

Thanks for your help, however.


More information about the nginx-devel mailing list