Welcome! Log In Create A New Profile

Advanced

Re: Re: what's the proper way to get module specific configuration in init_process

June 23, 2022 04:28AM
Thanks,

That means we need move some configuration commands form server to main
section. We will review the logic

Lei

On Thu, Jun 23, 2022, 01:51 Maxim Dounin <mdounin@mdounin.ru> wrote:

> Hello!
>
> On Mon, Jun 20, 2022 at 04:05:53PM +0800, shanlei@asiainfo.com wrote:
>
> > Hello, guys,
> >
> > Recently I have been working on an nginx c module, which have to
> > leverage on init_process routine.The logic is based on instruction
> > command which may be configured inside stream.server, I have to do some
> > work in the init_process routine, for example, to schedule a timer.
> > I did google a while ,and decide to using code snippet like below:
> >
> > ============================
> >
> > ngx_stream_conf_ctx_t conf_ctx = (ngx_stream_conf_ctx_t
> > *)ngx_get_conf(cycle->conf_ctx, ngx_stream_module);
> >
> > "module_spec_conf = conf_ctx->srv_conf["my_module".ctx_index];
> >
> > =============================
> >
> >
> > However, the module_spec_conf I got is the top_level ,that is created
> > when nginx parse the stream section, not the one created when nginx
> > parse the stream.server section, the later has the proper values.
> > Currently to got the later structure, I have to copy the configure value
> > back from child to parent in configuration merger function, which is
> > inconvenient and buggy when the stream includes multi servers.
> >
> > So I wonder what's the proper way to get module specific configuration
> > in the routine: init_process
>
> For the purpose of the init_process callback, the most simple
> approach would be to use your module's main configuration. For
> example, the embedded Perl module uses the init process callback
> to set correct PID in Perl interpreter: Perl interpreter is stored
> in the module's main configuration, and the init process callback
> uses the ngx_http_cycle_get_module_main_conf() macro to access it.
> See src/http/modules/perl/ngx_http_perl_module.c for details.
>
> (Just in case, corresponding macro in the stream module is
> ngx_stream_cycle_get_module_main_conf().)
>
> --
> Maxim Dounin
> http://mdounin.ru/
> _______________________________________________
> nginx-devel mailing list -- nginx-devel@nginx.org
> To unsubscribe send an email to nginx-devel-leave@nginx.org
>
_______________________________________________
nginx-devel mailing list -- nginx-devel@nginx.org
To unsubscribe send an email to nginx-devel-leave@nginx.org
Subject Author Views Posted

what's the proper way to get module specific configuration in init_process

shanlei 462 June 20, 2022 04:08AM

Re: what's the proper way to get module specific configuration in init_process

Maxim Dounin 178 June 22, 2022 01:52PM

Re: Re: what's the proper way to get module specific configuration in init_process

shanlei 156 June 23, 2022 04:28AM

Re: Re: what's the proper way to get module specific configuration in init_process

Maxim Dounin 143 June 23, 2022 04:48PM



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

Online Users

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