Vladimir Shebordaev
August 17, 2012 07:34AM
Hi,

2012/8/17 MAGNIEN, Thierry <thierry.magnien@sfr.com>:
>
> I am currently writing a module for my own needs and am facing a problem : at startup, I need to load into shared memory some content from a MySQL database.
>
> Shared memory size and mysql parameters (hostname, user, password) are in the main config section.
>
> My problem is I don't know where to insert the code so that it works :
> - I initialize shared memory in postconfiguration, but I can't load MySQl data here because the shm is not ready yet,
> - I tried to load MySQL data in init module function but then I can't access my module configuration directives (ngx_get_conf returns NULL).
>
> Does anybody have an idea how I could achieve this ?
>

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.

Hope it helps.

> Thanks,
> Thierry
>

--
Regards,
Vladimir

_______________________________________________
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 1431 August 17, 2012 06:00AM

Re: Pb with module initialization

Vladimir Shebordaev 665 August 17, 2012 07:34AM

RE: Pb with module initialization

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

RE: Pb with module initialization

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

Re: Pb with module initialization

Vladimir Shebordaev 492 August 17, 2012 08:58AM

RE: Pb with module initialization

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

Re: Pb with module initialization

Vladimir Shebordaev 559 August 17, 2012 09:38AM

Re: Pb with module initialization

Vladimir Shebordaev 678 August 17, 2012 10:02AM



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

Online Users

Guests: 169
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