Welcome! Log In Create A New Profile

Advanced

Re: Pb with module initialization

Vladimir Shebordaev
August 17, 2012 10:02AM
2012/8/17 Vladimir Shebordaev <vshebordaev@mail.ru>:
> 2012/8/17 MAGNIEN, Thierry <thierry.magnien@sfr.com>:
>>>>> 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 ?
>>>
>
> By the way, when the shm zone constructor is invoked by
> ngx_init_cycle() it gets the value of the data field of the shm zone
> descriptor from the old cycle as the second argument. NULL is passed
> there when the zone is initialized for the first time right after it
> is created anew.
>

Well, I rather mean that the shm zone is a global object
which live cicle is controlled by the server core, so the zone
contructor is the only proper place to manage the initialization. The
module init_process() and init_thread() methods are to solve other
tasks when the new worker process or thread is (re)spawned, those
events should not normally affect shared memory state, it is inherited
from the parent master process and is already mapped to the process
address space.

>>>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.
>>

Thanks for your question :)

>> Regards,
>> Thierry
>>

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

Pb with module initialization

MAGNIEN, Thierry 1422 August 17, 2012 06:00AM

Re: Pb with module initialization

Vladimir Shebordaev 661 August 17, 2012 07:34AM

RE: Pb with module initialization

MAGNIEN, Thierry 557 August 17, 2012 07:46AM

RE: Pb with module initialization

MAGNIEN, Thierry 571 August 17, 2012 08:54AM

Re: Pb with module initialization

Vladimir Shebordaev 489 August 17, 2012 08:58AM

RE: Pb with module initialization

MAGNIEN, Thierry 549 August 17, 2012 09:00AM

Re: Pb with module initialization

Vladimir Shebordaev 555 August 17, 2012 09:38AM

Re: Pb with module initialization

Vladimir Shebordaev 674 August 17, 2012 10:02AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 195
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready